views:

58

answers:

3

My iPhone (actually, iPad) app creates documents that consist of several images, plus a bit of metadata. What's the best practice for storing these sorts of documents on disk? I see two main options:

  1. Create a folder for each document, and store my images as separate PNG files within the folder (plus another little file for the metadata).

  2. Create a single file which contains all images and metadata.

But I'm not sure how to easily do option 2. I think I can convert my images in PNG format to/from NSData, but then what? I'm still a newbie at Cocoa, but I believe I saw something about stuffing mixed data into some NSSomethingOrOther and having this write itself out to disk, and read itself back in later. Does this ring a bell with anyone? And, will it work with large binary blobs of data like my images?

Or would you recommend I simply go with option 1?

A: 

Simply go with option1. It's clean, elegant, and simple to implement. You could even use (a subset of) HTML.

Michael Aaron Safyan
There's a trend to making single file documents for MacOS X, which may well spread to iPad apps as document support becomes better understood and adopted. The simple solution to doing this is to make a zip archive to contain what would have otherwise been separate files.
Paul Lynch
How simple is that in practice, though? There's no built-in support for zip files, is there?
Joe Strout
A: 

TIFFs and PDFs can have multiple pages.

Azeem.Butt