The Omni Group Forums

The Omni Group Forums (
-   Omni Frameworks (
-   -   Adding metadata to OUIDocument (

appapps 2013-04-24 10:29 AM

Adding metadata to OUIDocument
What is the best approach to add metadata to our OUIDocument subclass? I'm using the RTFDocument as an example and would like to add additional metadata to it such as keywords and PDF preview. Currently the RTFDocument example uses a flat NSData format rather than an NSFileWrapper, so the first step would be to address that. Something like this might work:

- (BOOL)readFromURL:(NSURL *)url error:(NSError **)outError;
self.fileWrapper = [[NSFileWrapper alloc] initWithURL:url options:nil error:outError];
NSString *rtfFilename = [url lastPathComponent];
NSFileWrapper *rtfWrapper = [self.fileWrapper.fileWrappers objectForKey:rtfFilename];
NSString *rtfString = [[NSString alloc] initWithData:[rtfWrapper regularFileContents] encoding:NSUTF8StringEncoding];
NSAttributedString *attributedString = [OUIRTFReader parseRTFString:rtfString];

_text = [attributedString copy];

return YES;


Since there is a reference to the NSFileWrapper from this point, I could lazy load the metadata file and PDF preview similarly. Or perhaps I could lazy load the rtf data as well, just to keep the object graph as small as possible when dealing with a collection of documents.

Any overall thoughts on this? I guess I'm just looking for a code smell more than anything else to make sure I didn't miss anything crucial.

All times are GMT -8. The time now is 05:59 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.