On Mon, Oct 6, 2008 at 5:26 PM, Erik Buck <[EMAIL PROTECTED]> wrote: > >> I am very confused here. KVO has nothing to do with a call like >> valueForKeyPath:, other than the obvious fact that they are both built >> on the idea of key paths. The >> observeValueForKeyPath:ofObject:change:context: method doesn't >> interact with valueForKeyPath: in any way, and so I don't really >> understand what you're getting at here. > >> If you don't override observeValueForKeyPath:ofObject:change:context:, >> how are you supposed to use KVO at all? As far as I understand it, >> that is the *only* way to get notified of changes to things you >> observe. > > Apple's various NSController subclasses handle KVO and bindings for you. > > NSController subclasses automatically call -valueForKeyPath: or -valueForKey: > or -setValue:forKey:. > > The -observeValueForKeyPath:ofObject:change:context: _does_ interact with > -valueForKeyPath: because the various NSController subclasses exist in part > to provide exactly that interaction. > > You do often need to call -bind:toObject:withKeyPath:options:. > > You really don't need to override > -observeValueForKeyPath:ofObject:change:context:. Or at least I haven't > needed to override it because one of the existing NSController subclasses > usually meets my needs.
So your assertion is, essentially, that KVO is not really intended to be a user-accessible mechanism but rather is internal support for more accessible mechanisms like bindings? If I want to, say, get notified when an NSOperation finishes, am I expected to instantiate an NSController just for that? If so, then I'm going to say that this makes things worse, not better. Having to create a whole new object and deal with that just to get a notification from another object is really terrible. As far as I can see the documentation doesn't support this idea at all. It goes right ahead and talks about how to register as an observer and listen for changes, complete with a broken example of overriding observeValueForKeyPath:ofObject:change:context: to accomplish it. Mike _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
