Re: How troubleshoot when Managed Object disappears from Store?
Re: How troubleshoot when Managed Object disappears from Store?
- Subject: Re: How troubleshoot when Managed Object disappears from Store?
- From: Jerry Krinock <email@hidden>
- Date: Mon, 2 Aug 2010 20:11:15 -0700
On 2010 Aug 01, at 20:59, Quincey Morris wrote:
> Are you sure this isn't just a memory management error, perhaps in combination with an incorrect delete rule? What's the delete rule for the "department" relationship in the "Employee" entity?
Nullify in both directions.
> Is there a strong reference that keeps the singleton "Department" alive even when there's no fetched "Employee" or unfaulted "Employee" in memory?
No.
Thanks, Quincey. You "got me thinking".
Further troubleshooting, I found that the "Department" object was disappearing during a call to -[NSPersistentDocument writeSafelyToURL:ofType:forSaveOperation:error:. The problem was that, prior to this invocation, for reasons which made sense at the time, I was sending setFileType: to the document and passing the document's filename extension. And this was reflected in the ofType: parameter in writeSafelyToURL:ofType:forSaveOperation:error:. During previous invocations of this method, which worked OK, ofType: was a UTI-style type, i.e. com.mycompany.MyApp.MyDocument. So, eliminating the errant setFileType: solved the problem.
Now on to the post mortem…
AM I THE ONLY ONE WHO HAS TROUBLE WITH "DOCUMENT TYPE"?
It seems to me that, throughout Cocoa documentation, Apple uses the phrase "document type" to mean three different things: Display Name, UTI, and Filename Extension. For example, in the documentation of -writeSafelyToURL:ofType:forSaveOperation:error:, the ofType: parameter is documented as "The string that identifies the document type." Grrrrrr.
I know I've submitted Document Feedback on this previously. I'm in the mood to file a formal bug. Am I just missing it somewhere?
WHY DID THE OBJECT DISAPPEAR?
Using com.apple.CoreData.SQLDebug=1, I noted that, during the save operation which caused the object to disappear, Core Data repeated the CREATE TABLE and CREATE INDEX sqlite commands, but it did not re-insert the object. That is, the table containing the object was being overwritten with a new empty table. (I'm surprised that receiving a CREATE TABLE command for a table that already existed didn't bring forth a barf from sqlite.)
Another observation: If I replaced writeSafelyToURL:ofType:forSaveOperation:error: with a -save: to the document's managed object context (which seems to have the disadvantage of not supporting 'Save As' operations), it also worked OK.
Can anyone suggest why an incorrect "type" of "file type" causes writeSafelyToURL:ofType:forSaveOperation:error: to hose its sqlite store?
Jerry
_______________________________________________
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