Re: NSDictionary valueForKeyPath:
Re: NSDictionary valueForKeyPath:
- Subject: Re: NSDictionary valueForKeyPath:
- From: Ken Thomases <email@hidden>
- Date: Sun, 14 Dec 2008 10:06:22 -0600
On Dec 14, 2008, at 9:21 AM, email@hidden wrote:
I was surprised to learn that a hierarchy of NSDictionary objects
can be queried with valueForKeyPath:
NSDictionary *dict0 = [NSDictionary
dictionaryWithObjectsAndKeys:@"got me!", @"2", nil];
NSDictionary *dict = [NSDictionary
dictionaryWithObjectsAndKeys:dict0, @"1", nil];
NSLog([dict valueForKeyPath:@"1.2"]);
This is powerful functionality.
Am I blind (again), or is this fact omitted from the docs? Or is it
implicit from the nature of KVC?
It's implicit in two facts:
1) The default implementation of -valueForKeyPath: resolves down to a
series of -valueForKey: calls
2) The override of -valueForKey: on NSDictionary resolves to a call to
-objectForKey: in most cases
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden