On 5/15/13 5:14 PM, Trygve Inda wrote:
My document format needs to look like:

File (actually a directory marked as a package)
-- MyData.plist
-> Images (directory)
----> Image1.png
----> Image2.png
-> Data (directory)
----> Data1.dat
----> Data2.dat
-> Icons (directory)
----> Icon1.png
----> Icon1.png


In my NSDocument subclass, Overriding:

- (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper
ofType:(NSString *)typeName error:(NSError **)outError

Doesn't seem to be the right thing to do since it seems to want to put all
the files in a single flat directory within the package

It's the right place. You'll get a filewrapper representing the document-package directory (the root). From there, you can query the root wrapper for sub-wrappers using -fileWrappers (use -isDirectory and -isRegularFile to find out if a wrapper contains other wrappers).

For writing the document, you'll overwrite -fileWrapperOfType:error: and return a root wrapper that contains your entire package structure. You can construct the interior of your package format to your liking, you can also add directories by adding a file wrapper that represents a directory - created via -initDirectoryWithFileWrappers:

The NSDocument guide contains a section about using wrappers and demos the 
basics:

http://developer.apple.com/library/mac/#documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/AdvancedTopics/AdvancedTopics.html

Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to