Report-an-Apple-Bug Friday! 70
This bug is Borken implementation of -setNilValueForKey:
in Model Object Impl Guide. It was filed on 2007-09-14 at 12:24 PDT.
Summary:
The Model Object Implementation Guide presents an example implementation of -setNilValueForKey:
that can hide bugs.
Steps to Reproduce:
- Copy the implementation of
-setNilValueForKey:
from page 16 of the MOIG into your custom model-object class. - Attempt to set
nil
for any key other thanbounds
(bounds
being the key handled by the implementation presented in the MOIG).
Expected Results:
You get an NSInvalidArgumentException
from -[NSObject setNilValueForKey:]
.
Actual Results:
The program whistles innocently, the nil
is dropped on the floor, and the model object’s value for the key remains unchanged.
Notes:
The correction is for the overriding setNilValueForKey:
to pass the message up to super
when it doesn’t recognize the key. Then, for all keys not recognized by the overriding implementation, an NSInvalidArgumentException
will be raised, as expected.
September 14th, 2007 at 19:42:18
Do you have some unclosed tag somewhere in here? The text keeps getting smaller and smaller as you go down the entry page! The text is all diving into a black hole!
September 14th, 2007 at 20:05:24
Oops, sorry. I had a couple of <code>s that I forgot to change to </code>s. Copy-and-paste error. They’re fixed now.
September 16th, 2007 at 15:39:57
Clever doc bug. But, is it really “Borken”?
September 16th, 2007 at 18:03:35
A subclass method that, by omission of an important call to the superclass, hides bugs, itself contains a bug; thus, it is borken.