The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   Omni Frameworks (http://forums.omnigroup.com/forumdisplay.php?f=16)
-   -   Adding metadata to OUIDocument (http://forums.omnigroup.com/showthread.php?t=29263)

appapps 2013-04-24 09: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:

[CODE]
- (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;
}

[/CODE]

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 08:04 PM.

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