Reputation: 777
I have created an NSDictionary named "myData" which contains the following JSON response:
{
listInfo = (
{
date = 1392157366000;
dateAsString = "02/11/2014 22:22:46";
id = 6;
address = 542160e0000c;
myLevel = 13;
},
{
date = 1392155568000;
dateAsString = "02/11/2014 21:52:48";
id = 5;
address = 542160e0000c;
myLevel = 13;
}
);
}
I need to retrieve each of the [dateAsString] key/value pairs. I've tried: NSString *dateAsString=[[myData valueForKeyPath:@"dateAsString"][0] objectForKey:@"myData"]; without any luck.
Any suggestions are greatly appreciated.
Upvotes: 0
Views: 104
Reputation: 5655
I think this will work:
NSArray* dateStringArray = [listInfo valueForKeyPath:@"@unionOfObjects.dateAsString"]
I believe it will give you an array of strings. If you need to stuff that back in a dictionary, that should be fairly easy.
It's not clear what your "myData" looks like... so I used the listInfo array of dicts shown.
Upvotes: 2