• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: wasting space?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wasting space?


  • Subject: Re: wasting space?
  • From: "Michael Ash" <email@hidden>
  • Date: Mon, 6 Oct 2008 18:05:35 -0400

On Mon, Oct 6, 2008 at 5:26 PM, Erik Buck <email@hidden> 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@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

References: 
 >Re: wasting space? (From: Erik Buck <email@hidden>)

  • Prev by Date: Re: Universal app fails on PPC.
  • Next by Date: [Moderator] Re: Open SSL on the iPhone
  • Previous by thread: Re: wasting space?
  • Next by thread: Re: wasting space?
  • Index(es):
    • Date
    • Thread