Skip navigation.
 
mlRe: KVO and the observeValueForKeyPath bottleneck
FROM : Matt Neuburg
DATE : Mon Jul 17 19:49:37 2006

On Mon, 17 Jul 2006 09:09:04 -0700, Chris Kane <<email_removed>> said:
>On Jul 17, 2006, at 7:38 AM, Matt Neuburg wrote:
>

>> On or about 7/17/06 3:38 AM, thus spake "Jakob Olesen"
>> <<email_removed>>:
>>

>>> - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)
>>> object change:(NSDictionary *)change context:(void *)context
>>> {
>>>      if ([self respondsToSelector:(SEL)context])
>>>          [self performSelector:(SEL)context withObject:change];
>>> }

>>
>> By an incredible coincidence, yesterday (before this reponse
>> arrived at my
>> desk), after considering all the responses I'd gotten, I decided
>> upon an
>> approach and implemented it in my app, and it was word for word,
>> letter for
>> letter identical with this. m.

>
>
>I'm just curious ... with the trivial approach above, and the other
>ones involving the context being a keypath and so on ...  has anyone
>considered what will happen if a superclass or subclass (of whatever
>class that is) is also doing KVO (on either same or different keys)
>of the same objects?


I hadn't, but I presume you wouldn't be asking the question unless the
answer were, "Something bad...?" :) I guess you're hinting that one needs to
call super.

Still, isn't it the strange implementation of KVO itself that gets us into
this bind? I mean, we can call super as part of the above implementation,
but aren't you really saying that we *always* need to call super, or KVO
will break down? The docs do not mention this (though, to be fair, the
example in KVOBasics.html does in fact call super). So this is a trap that
one was always prone to fall into, regardless of how observeValue... was
implemented.

The thing I'm really wondering is: Why was KVO implemented in this oddly
bottleneck-based way? There is terrific prior art, in the form of ordinary
notifications and the notification center (broadcaster-type architecture);
is there some technical reason why KVO doesn't use that?

m.

--
matt neuburg, phd = <email_removed>, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>

Related mailsAuthorDate
mlKVO and the observeValueForKeyPath bottleneck Matt Neuburg Jul 14, 19:44
mlRe: KVO and the observeValueForKeyPath bottleneck George Orthwein Jul 15, 07:36
mlRe: KVO and the observeValueForKeyPath bottleneck Aaron Burghardt Jul 15, 22:56
mlRe: KVO and the observeValueForKeyPath bottleneck Jakob Olesen Jul 17, 12:38
mlRe: KVO and the observeValueForKeyPath bottleneck Jakob Olesen Jul 17, 13:03
mlRe: KVO and the observeValueForKeyPath bottleneck Matt Neuburg Jul 17, 16:38
mlRe: KVO and the observeValueForKeyPath bottleneck Jakob Olesen Jul 17, 16:57
mlRe: KVO and the observeValueForKeyPath bottleneck Matt Neuburg Jul 17, 17:31
mlRe: KVO and the observeValueForKeyPath bottleneck Chris Kane Jul 17, 18:09
mlRe: KVO and the observeValueForKeyPath bottleneck Matt Neuburg Jul 17, 19:49
mlRe: Re: KVO and the observeValueForKeyPath bottleneck Michael Ash Jul 17, 20:11
mlRe: KVO and the observeValueForKeyPath bottleneck Chris Kane Jul 17, 20:24
mlRe: KVO and the observeValueForKeyPath bottleneck Matt Neuburg Jul 17, 20:31
mlRe: KVO and the observeValueForKeyPath bottleneck Scott Anguish Jul 17, 22:00
mlRe: KVO and the observeValueForKeyPath bottleneck Chris Kane Jul 17, 22:42
mlRe: KVO and the observeValueForKeyPath bottleneck Jakob Olesen Jul 17, 23:16
mlRe: KVO and the observeValueForKeyPath bottleneck Matt Neuburg Jul 18, 00:43
mlRe: KVO and the observeValueForKeyPath bottleneck Chris Kane Jul 18, 03:00
mlRe: KVO and the observeValueForKeyPath bottleneck Jim Correia Jul 18, 05:37
mlRe: KVO and the observeValueForKeyPath bottleneck Jakob Olesen Jul 18, 16:06
mlRe: KVO and the observeValueForKeyPath bottleneck Jim Correia Jul 18, 18:11
mlRe: KVO and the observeValueForKeyPath bottleneck Matt Neuburg Jul 19, 02:44
mlRe: KVO and the observeValueForKeyPath bottleneck George Orthwein Jul 20, 21:25
mlRe: KVO and the observeValueForKeyPath bottleneck Scott Anguish Jul 20, 22:14
mlRe: KVO and the observeValueForKeyPath bottleneck Matt Neuburg Jul 21, 03:57
mlRe: KVO and the observeValueForKeyPath bottleneck Scott Anguish Jul 21, 10:11
mlRe: KVO and the observeValueForKeyPath bottleneck George Orthwein Jul 21, 17:46
mlRe: KVO and the observeValueForKeyPath bottleneck Scott Anguish Jul 21, 23:01