Skip navigation.
 
mlRe: KVO and the observeValueForKeyPath bottleneck
FROM : Matt Neuburg
DATE : Tue Jul 18 00:43:01 2006

On or about 7/17/06 1:42 PM, thus spake "Chris Kane" <<email_removed>>:

> On Jul 17, 2006, at 1:00 PM, Scott Anguish wrote:

>> On Jul 17, 2006, at 2:31 PM, Matt Neuburg wrote:

>>> <http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving

>>> /Concepts/KVOBasics.html#//apple_ref/doc/uid/20002252-179866>
>>>
>>> (Interestingly, the comment in that example is completely different
>>> from the
>>> comment in the copy on my machine.) The code shown in the example
>>> will break
>>> if super is NSObject. So perhaps I should file a bug on the docs.

>>
>> Actually, that was why it says "if it implements it".  Now I
>> suppose one could argue that NSObject does implement it, but as
>> Chris said, it just throws.

>
> The problem with that would be that "if it implements it" can change
> over time.  Next month you change a superclass of the class to start
> listening for KVO notifications (perhaps you install a software update
> of the OS!), and ... your hard-coded knowledge of what the super class
> did and didn't do is no longer true.
>
> You can't just blindly call super, and face the exception (hmm, is the
> exception there for a reason? could be a clue), but if you don't you
> cut off your superclasses from receiving necessary KVO notifications,
> given the design.


And there's a memory management problem. The "context" is not automatically
retained. Therefore if ClassA provided a context, only ClassA knows whether
that context needs to be released (or what it means). Gosh, this looks
troublesome on *any* implementation.

So ClassB needs a way to distinguish the notifications that belong to it (so
that it can pass along those that don't). The only way I can think of to do
this is to include an unmistakeable token in the context. But what would
this be - a hard-coded string? Yuck. m.

--
matt neuburg, phd = <email_removed>, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119
Take Control of Word 2004, Tiger, and more -
http://www.takecontrolbooks.com/tiger-customizing.html
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/

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