Re: Problem with "save as" and freed managed object context
Re: Problem with "save as" and freed managed object context
- Subject: Re: Problem with "save as" and freed managed object context
- From: Gideon King <email@hidden>
- Date: Mon, 15 Mar 2010 13:23:24 +1000
Thanks Ben
One of the other things I had been working on must have fixed the underlying problem, and my implementation of identifier and setIdentifier were actually causing this issue. I completely removed those two methods (which is of course going directly against the documentation at the top of the NSAtomicStore class reference, but going along with the implication in NSPersistentStore that you don't have to override it) and for the first time, was able to "save as"! Yay!
But my elation was short lived because I now get an intermittent error on save as:
Error Domain=NSCocoaErrorDomain Code=4 UserInfo=0x11e9c21c0 "The document “Untitled60.nm5” could not be saved as “Untitled60sa.nm5”. The folder doesn’t exist." Underlying Error=(Error Domain=NSCocoaErrorDomain Code=4 UserInfo=0x11ef217f0 "The folder “(null)” doesn’t exist." Underlying Error=(Error Domain=NSPOSIXErrorDomain Code=2 "The operation couldn’t be completed. No such file or directory"))
So sometimes it works and sometimes it doesn't. My file format is a zipped folder with my XML files and other resources in it, so when a file is saved, I create a temporary folder and put all the bits of my file into it, zip it up, and then remove the old file and move the zipped up new one into place. I'm not sure if this is relevant at all, but when I get the save error, it also says:
AppKit called rmdir("/private/var/folders/nl/nlcXN-oPHJiAXXc1Z0R5VE+++TI/TemporaryItems/(A Document Being Saved By NovaMind5TP 71)"), it didn't return 0, and errno was set to 66.
But I am collecting the error messages in my app, and it's not anywhere in there, so must be from within CoreData, and the man page for rmdir just said that the return on error is >0 for errors, so I can't be certain what the error code means (I suspect it means that the folder is not empty).
Has anyone else seen that one before?
I also have a problem where the save as only appears to save some of the data in my file, but I am guessing that that must be some bug in my code.
If I open a file and then try to "save as" (without making any changes), then I get a "Could not merge changes" error message. I'm not sure if that's related to the problem where it is only saving part of the file, or is something completely different, but am planning to look at the data loss one first and see if it resolves the merge issue.
Regards
Gideon
On 15/03/2010, at 8:30 AM, Ben Trumbull wrote:
> That particular function is trying to CFRetain the result of -identifier on your store. If you've overridden it, make sure it never returns nil and it always returns the same UUID at least until someone calls -setIdentifier. The UUID should also be set in the store's metadata with the key NSStoreUUIDKey. If you're not preserving the store metadata, including any keys Core Data might set, then you'll have these kinds of problems.
>
> - Ben
>
_______________________________________________
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