Folks;

Annoyed that something was amiss I have respecified the various bits of code and it all now works as I knew Cocoa would.. Best explanation I can offer is some spelling error in key handling of which I was blinded..
Sorry for the nuisance on the list!   [:-(
Steve

This code works:
NSMutableDictionary *address = [NSMutableDictionary dictionaryWithCapacity:7];
[address setObject:@"BoomTown" forKey:@"city"];
//more values set here..
NSMutableDictionary *myPerson = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                                                 @"Bob", 
@"name",
                                                                 address, 
@"homeAddress",
        nil];
NSLog(@"keyPath = %@", [myPerson valueForKeyPath:@"homeAddress.city"]); //BoomTown NSLog(@"keys = %@", [[myPerson valueForKey:@"homeAddress"] valueForKey:@"city"]); //BoomTown


On Apr 30, 2009, at 7:29 PM, Ulai Beekam wrote:


Because just adding a key to a dictionary does not make it key-value- coding compliant with respect to that key. KVC is needed for key paths like that to work.


----------------------------------------
From: steve_cro...@mac.com
To: cocoa-dev@lists.apple.com
Date: Thu, 30 Apr 2009 19:00:51 -0500
Subject: valueForKeyPath

Folks;

I have a mutable dictionary 'myPerson' which has a key=@"address".
The object stored at @"address" is another mutable dictionary.

someCity = [myPerson valueForKeyPath:@"address.city"] --> nil

someCity = [[myPerson valueForKey:@"address"] valueForKey:@"city"] --
expected value

Why does -valueForKeyPath not work in this circumstance?

Steve

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/ulaibeekam%40hotmail.com

This email sent to ulaibee...@hotmail.com

_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to