On Wed, Oct 29, 2008 at 4:46 PM, Joel Norvell <[EMAIL PROTECTED]> wrote: > Dear Cocoa-dev People, > > First, I wanted to thank Aki Inoue and Rob Keniger for pointing out the > problem with my NSData->NSString->NSData approach. > > As an alternative, would it be fruitful to use a Directory Wrapper to > represent the data as two files; one the metadata and the other the pdf? > Then I could work with the metadata file, but just display the pdf file. > > In the "What could go wrong here?" department, would my compound file end up > behaving like a directory (or worse)?
Depending on your goals, there may be better alternatives. If you don't care about having this PDF file be readable by other programs (like your initial PDF-and-metadata-appended-together format wouldn't be) then you just need a better metadata+PDF format. I'd suggest a property list for this. Create an NSDictionary. For one key, perhaps called @"pdfdata", set the PDF data as the value. Use one or more other keys for your metadata. Be sure to keep this as property list objects, which are approximately limited to dictionaries, arrays, strings, NSData, NSNumber, and NSDate. Then use NSPropertyListSerialization to read and write the dictionary to serialized form. If you do this, note that the XML format will expand your data by a factor of 33% as it gets stored base64 encoded. The binary format does not suffer from this, as the data gets stored directly (obviously with some framing around it, but no constant expansion). This could be important if your PDF data is potentially enormous. If you want your PDF to be readable by other apps then another thing you could do is to use extended attributes. These store metadata at the filesystem level, which can be read and written using getxattr() and setxattr(). (They have man pages if you want more info.) Beware that there is an annoyingly small limit on the size of extended attributes, something around 4kB. So while this is a good solution if your metadata is small, it's a pain to use if it's potentially large. Mike _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
