I want to use valueForKeyPath
on my NSDictionary
, but the problem is that one of the keys is a string that starts with the @ symbol. I have no cont
Just to update this old question a little...
The reason that these:
[dict valueForKeyPath:@"key1.@specialKey.key3"]
[dict valueForKeyPath:@"key1.@@specialKey.key3"]
...fail is that any "@" symbols in a key path are interpreted as being collection's operators as with:
[dict valueForKeyPath:@"key1.@sum.key3"] // returns the sum of all 'key3' values
[dict valueForKeyPath:@"key1.@avg.key3"] // returns the average of all 'key3' values
The nested key calls:
[[[dict objectForKey:@"key1"] objectForKey:@"@specialKey"] objectForKey:@"key3"]
... work because a single key is not processed as a key path.