Binding to methods of an object
Binding to methods of an object
- Subject: Binding to methods of an object
- From: "Christopher Hickman" <email@hidden>
- Date: Wed, 17 May 2006 16:45:31 -0400
The docs say "NSObjectController exposes a single binding for content called
contentObject. You can establish a binding from contentObject to any object
that is key-value-coding and key-value-observing compliant for the keys that
you intend to have the controller operate on."
So if I want to bind to a KVO compliant method someAccessor in my Model
object, I can drag an NSObjectController into my nib, bind its contentObject
to my instantiated Model object, and then bind interface elements to the
controller with the Controller Key: "contentObject" and the Model Key Path:
someAccessor, right?
I think this Cocoa Bindings stuff is starting to make sense to me, but I'm
not sure. The docs say "Controllers can be configured in one of two modes:
object mode or entity mode. In object mode the content class is specified by
the method setObjectClass: or in the controller inspector panel in Interface
Builder." and "If the controller is in object mode, the method newObject is
used to create new objects. The default implementation simply allocates a
new object of the class specified by objectClass or the entityName and sends
the object a standard init message with no arguments."
In my above scenario, my Model object is already instantiated, and I don't
want the controller making new instances. As long as I don't call the
controller's newObject method, it's just going to use the one I've
instantiated and bound to contentObject, right?
Can an NSObjectController's contentObject be bound to keys in other
controller objects, such as a dictionary entry in user defaults using
NSUserDefaultsController? My attempts so far have failed (but I've been
trying to bind outside of my own persistent domain, and I haven't figured
out how to construct the model key path for that).
Topher
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden