Re: Managed Object Context Reference
Re: Managed Object Context Reference
- Subject: Re: Managed Object Context Reference
- From: Joanna Carter <email@hidden>
- Date: Mon, 31 May 2010 22:40:04 +0100
Hi Richard
> Apple's documentation seems to indicate that if you have an object in a nib with a managed object context outlet, that you can somehow set the outlet.
>
> The Core Data Programming Guide states "If you are setting the reference to the context in a nib file, make sure the appropriate outlet or binding is set correctly."
>
> http://developer.apple.com/mac/library/documentation/cocoa/conceptual/CoreData/Articles/cdTroubleshooting.html#//apple_ref/doc/uid/TP40002320-SW23
>
> How do you set a managed object context outlet in a nib file?
The typical scenario when you would connect something in a NIB file to a MOC is when you set the binding for the MOC of an NSArrayController or NSObjectController, etc.
Normally, I find it easier to write read-only, lazy instantiating, properties for the Persistent Store Coordinator, MOM and MOC, in the Controller., Then it is easy to bind any objects in the NIB, that require the MOC.
> Suppose that I have a custom view with a managed object context outlet and I want to bind it or set it in the nib to the managed object context of the File's Owner which is a subclass of NSPersistantDoument. How would you do this?
It would be unusual to have a MOC directly connected to a View. They are normally connected to array or object controllers in the controller.
To connect something like an array controller, simply go to the Bindings sheet of the Inspector for the array controller, expand the Managed Object Context section and bind to the File's Owner and the name of the MOC property that you declared, as the Model Key Path.
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
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