Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)
Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)
- Subject: Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)
- From: Jerry Krinock <email@hidden>
- Date: Sat, 25 Oct 2008 18:54:03 -0700
On 2008 Oct, 25, at 13:01, Quincey Morris wrote:
Well, it's not clear what class your -document getter belongs to, or
why you're expecting it to be referenced by code you didn't write.
Core Data knows nothing about documents. NSPersistentDocument
"merely" wraps document behavior around Core Data.
I was assuming that Core Data would "wrap" around the document, not
the other way around as you stated.
Probably one thing which misled me to this wrong idea was that the
data model is named "MyDocument.xcdatamodel". But now I realize
that's just a decoration and does not tie it to the MyDocument class
in any way. I changed the name to "MyProject.xcdatamodel" and
everything still works.
For a new document, the Core Data object graph is empty, and there's
no automatic hook in either Core Data to add objects to the initial
object graph (i.e. the department object in your case). Normally,
it's either done in initWithType: or by using "prepares content
automatically" in an object/array/etc controller in the nib file.
Well, I did another experiment, which I shall not describe in detail.
However, the results proved that no one is directly accessing the
instance variable 'department' as I had assumed. Indeed, it is the
act of inserting a "Department" entity managed object into the managed
object context (or, as you said, "add objects to the initial object
graph") that is necessary the new-document UI to "work".
Thanks again, Quincey.
_______________________________________________
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