Tuesday, May 3, 2011

Save documents as folders, like Pages, Numbers, etc...

What's the right way to go about saving data like Pages, Numbers and other OSX applications do? That is, it looks like a file to the user, but is in fact a directory (a bundle?) containing a variety of stuff. I have some fairly complex data that I'd like to store in the same way; in particular, some sensor data that needs to be associated with video files.

From stackoverflow
  • The Apple official docs on the topic are probably a good starting point.

    From the Pages Info.plist file:

    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>pages</string>
            </array>
            [...]
            <key>LSTypeIsPackage</key>
            <true/>
            [...]
        </dict>
    </array>
    

    seem to be what does the trick.

    Dan : Ahh, that's it! A remarkably difficult topic to search upon without knowing what it's called!
  • It also looks like NSFileWrapper may be part of the answer: Document-Based Applications Overview FAQ.

0 comments:

Post a Comment