NSDocument fileWrapperOfType:: invalidates returned wrapper, options?
NSDocument fileWrapperOfType:: invalidates returned wrapper, options?
- Subject: NSDocument fileWrapperOfType:: invalidates returned wrapper, options?
- From: Markus Spoettl <email@hidden>
- Date: Mon, 11 Jun 2012 22:53:12 +0200
I have an NSDocument based app that has uses packages do to store a complex
structure.
When I open a document, I keep the wrapper around handed to the document in
-readFromFileWrapper:ofType:error:
in order to lazy-load parts of the package when my app needs them. Similarly, I
keep the wrapper when saving (which is the same object unless it's a new
document that didn't have a wrapper before). And here the trouble starts.
For some reason, when I try to lazy-load package files located down the wrapper
hierarchy after saving, they are still available (meaning the sub-wrapper
objects are there) but the content returned by -regularFileContents is nil.
The documentation states that this can happen when the user moves the file after
the wrapper has been created. I suspect that this is a side effect of
safe-saving, which writes temporary files and moves them into place when
everything worked out correctly.
I'm "fixing" this by calling -readFromURL:options:error: on the document
package's root wrapper in the completionHandler of NSDocument's
-saveToURL:forSaveOperation:completionHandler:
but it doesn't feel right. I'm wondering if there's a better way to make sure
the wrapper points to the right place once saving is complete.
Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden