Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView's "data" binding




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSTextView's "data" binding (From: Yann Bizeul <email@hidden>)
 >Re: NSTextView's "data" binding (From: mmalc crawford <email@hidden>)
 >Re: NSTextView's "data" binding (From: mmalc crawford <email@hidden>)
 >Re: NSTextView's "data" binding (From: Yann Bizeul <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.