Key-value coding and dictionaries (was Re: Weird behavior in NSMutableDictionary)
Key-value coding and dictionaries (was Re: Weird behavior in NSMutableDictionary)
- Subject: Key-value coding and dictionaries (was Re: Weird behavior in NSMutableDictionary)
- From: Jeremy Dronfield <email@hidden>
- Date: Sat, 18 Dec 2004 17:25:25 +0000
On 18 Dec 2004, at 1:28 pm, Steven Kramer wrote:
Op 18-dec-04 om 13:06 heeft Jeremy Dronfield het volgende geschreven:
What you're missing is key value coding. The NSDictionary and
NSMutableDictionary docs are strangely disingenuous in their
definitions for these methods. -valueForKey: and -setValue:forKey:
are not in fact dictionary methods. They are methods in the
NSKeyValueCoding informal protocol, which is implemented by NSObject.
It's worth reading up the documentation on this protocol, if only so
you know what's going on when you invoke its methods (and what it's
limitations and requirements are). One useful feature, for example,
is support for non-object parameters and return values, which are
wrapped and unwrapped automatically. See:
<file:///Developer/ADC Reference Library/documentation/Cocoa/
Conceptual/KeyValueCoding/index.html#//apple_ref/doc/uid/10000107i>
I'm pretty sure NSDictionary overrides valueForKey to do simply
objectForKey. IIRC the documentation states this explicitly...
somewhere. Type wrapping is not really possible/useful because the
dictionary can only contain id types anyway.
You're quite right. Although I wouldn't describe the documentation on
this as "explicit". Say rather "inscrutable". Somewhere in the murky
depths of Foundation, one presumes there is a reason for overriding
these methods just so they can call existing primitives...? Is this
merely a stop-gap until NSDictionary supports key-value coding more
fully?
Regards,
Jeremy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden