Search code examples
objective-cxcodemacosnsdocument

Xcode - Document Based Application (Document Bundle)


I'm trying to find a somewhat more comprehensive writeup, or an example to refer to regarding a Document Based Application which saves it's contents to a document bundle rather than a single file.

A good example of what I mean by a document bundle is how Pages saves it's documents i.e.

Document Name.myextension\
                          directory1\
                                     somefile.ext
                                     somefile2.ext
                          directory2\
                          directory3\
                          file1.png
                          file2.png

As we know apples documentation, although extensive, can, at the best of times be somewhat daunting to work with :-/

Any help would be appreciated!

Thanks

Ade


Solution

  • Take a look at the following Stack Overflow question:

    NSDocument to hold a complete folder?

    If the answer to that question isn't detailed enough, you can read the following article on file packages:

    Working with Cocoa File Packages

    Regarding Apple's documentation, the relevant classes to look at are NSFileWrapper, NSData, and NSDocument.