Re: NSTextView's "data" binding
Re: NSTextView's "data" binding
- Subject: Re: NSTextView's "data" binding
- From: mmalc crawford <email@hidden>
- Date: Sun, 29 Apr 2007 15:28:29 -0700
On Apr 29, 2007, at 3:04 PM, Yann Bizeul wrote:
Now I see different documentations on how to implement bindings in
custom views (includng your GraphicsBindings) and I'm a bit confused/
disappointed :
Do you want to use a custom view, or NSTextView?
In almost every examples I saw, it seems that I have to implement
KVO myself in
- (void)bind:(NSString *)bindingName
toObject:(id)observableObject
withKeyPath:(NSString *)observableKeyPath
options:(NSDictionary *)options
It's not clear what you mean.
In your bind method, you must add yourself as an observer of an object
to which you are bound. That doesn't seem unreasonable or an
imposition of a significant overhear -- it's one method call.
but I thought NSObject was KVO compliant so that when I
willChangeValue / didChangeValue, it was responsabile of annoucing
the chages to every observers, automatically setup in
bind;toObject:withKeyPath:options: implementation of NSObject.
An object that is KVO compliant does send KVO notifications to objects
that are registered observers. Typically you don't have to do
anything yourself to support this -- see <http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/AutoVsManual.html
>.
If you're not sure which way round bindings work, I would strongly
suggest re-reading the documents I cited earlier and trying some of
the more basic tutorials before spending more time on implementing a
custom view. I would then suggest looking at the Joystick example (<http://developer.apple.com/samplecode/BindingsJoystick/
>) which is a full implementation of the example used in the
documentation. It shows what observation you need to set up in the
bind:... method, and how to implement the observe... method.
mmalc
_______________________________________________
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