On 2010 Jul 01, at 15:38, I wrote:

> I'm debugging a problem with Save As in a Core Data document...

Yeah, I know, that original post was a long shot.

I fixed the problem but still don't understand it.

The "Save As" operation I was debugging is actually a home-made one which also 
deletes the original.  I had implemented this by sending -[NSPersistentDocument 
writeSafelyToURL:ofType:forSaveOperation:error:], and manually moving the files 
and setFileURL: in code.  Upon waking from a nap, I replaced this message with 
-[NSManagedObjectContext save:], and the problem went away.

Actually, there was another problem I didn't mention in my first post, and that 
problem went away too.  The second problem was that, during the save, Core Data 
would register a single Undo invocation which had a nil target, with selector 
_noop: and argument of type __NSArray0*, which had a -count = 0.  (Thanks to 
Graham Cox' GCUndoManager for that peek!)  Obviously this action was a no-op, 
but it dirtied my red button, etc.

In NSPersistentDocument documentation, the only one of the save/write methods 
overridden from NSDocument is supposedly 
writeToURL:ofType:forSaveOperation:originalContentsURL:error:, which is the 
next lower-level method invoked by 
writeSafelyToURL:ofType:forSaveOperation:error:.  So I don't see what the 
problem was.  Anyhow, since I'm taking care of the high-level file management 
stuff as explained above, I'm satisfied that -[NSManagedObjectContext save:] 
should be sufficient, and it seems to work.

"Message Flow In the Document Architecture" [1] is possibly the single most 
useful "Programming Guide" page on developer.apple.com, but it doesn't cover 
the little variations for Core Data.  I just submitted Document Feedback 
suggesting that they do so.

Jerry


[1] 
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Documents/Articles/ObjectInteractions.html

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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

This email sent to arch...@mail-archive.com

Reply via email to