PDA

View Full Version : File Packages




ATG
Sep 1, 2006, 04:08 AM
I want to be able to store different files within my app's file. I thought the best way to go about it would be to use file packages in the same way as apple pages. However, there seems to be no documentation on the subject. There is a 'package' check box in the target file types inspector but I don't know how I am supposed to use it!

Does anybody know how I can do this?



robbieduncan
Sep 1, 2006, 04:20 AM
There is so documentation. Assuming you want 10.3 compatibility (if you only need 10.4 and above there are other methods) you want to use (in NSDocument):

loadFileWrapperRepresentation:ofType: (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDocument/loadFileWrapperRepresentation:ofType:)

and provide data to save with:

fileWrapperRepresentationOfType: (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDocument/fileWrapperRepresentationOfType:).

The NSFileWrapper (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSFileWrapper_Class/) class provides most of what you need.

You may also want to read FolderBasedDocuments (http://www.cocoadev.com/index.pl?FolderBasedDocuments), NSFileWrapper (http://www.cocoadev.com/index.pl?NSFileWrapper) on cocoadev.

ATG
Sep 1, 2006, 04:40 AM
Thanks so much! :D

I can't believe I didn't see that :rolleyes: .

Thanks again :)