Re: How does NSArrayController bind to data model from IB?
Re: How does NSArrayController bind to data model from IB?
- Subject: Re: How does NSArrayController bind to data model from IB?
- From: "R. Matthew Emerson" <email@hidden>
- Date: Mon, 4 Jun 2007 00:17:27 -0400
On Jun 3, 2007, at 4:07 PM, Mike - wrote:
Short version: How does an NSArrayController in IB "see" entities
in a data model (when I enter an attribute value for "Entity Name")?
If I understand what you're asking, it simply remembers them once you
type them in.
CheckIn's MyDocument.nib has an NSArrayController named
ReleasesController. Its specified entity is "VersionRelease," which
is modeled in MyDocument.xcdatamodel. Its managedObjectContext is
bound to File's Owner (MyDocument). In the UI under Bindings for
the table view's corresponding column, ReleasesController is
selected and under Model Key Path I can see the list of attributes
from the VersionRelease entity modeled back in XCode.
When I try to replicate this in my Core Data application I can't
browse the attributes for Model Key Path in the same way. IOW it
doesn't seem to "see" the model attributes through the controller.
There does seem to be some magic provided by NSPersistentDocument,
so I have my File's Owner inheriting from a subclass of this class
(called MainDocument).
There's no magic. I don't think it's a good idea to do that if
you're not using the document architecture.
If you're using the Core Data Application template, then the Core
Data stack is set up in the application delegate. Bind your array
controller's managedObjectContext to Shared Application with a key
path of delegate.managedObjectContext. You could also bind to the
instantiated delegate object in the nib (if you're using the template).
Set the class/entity of the array controller, and you should be ready
to go. Initially, you'll have to type in the model key paths by hand.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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