FROM : Chris Kane
DATE : Mon Jul 17 22:42:26 2006
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.
Nobody's figured out the tricky problem yet ....
[I didn't design KVO, I'm just a bystander.]
Chris Kane
Cocoa Frameworks, Apple
DATE : Mon Jul 17 22:42:26 2006
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.
Nobody's figured out the tricky problem yet ....
[I didn't design KVO, I'm just a bystander.]
Chris Kane
Cocoa Frameworks, Apple






Cocoa mail archive

