Friday 28 February 2014

JSON obj c

Get values of particular key in nsdictionary:

 I refered this link for this blog.(http://stackoverflow.com/questions/16233425/get-values-of-particular-key-in-nsdictionary)

HERE IS THE PASTIE URL FOR JSON DATA :
http://pastie.org/8811638


Now Check the Scenario for the getting objects.

Following will give you the desired object :

NSDictionary *dict=[results valueForKeyPath:@"data.abcd"][0];

For individual:

NSString *categoryString=[[results valueForKeyPath:@"data.abcd"][0] objectForKey:@"Category"];
NSString *idString=[[results valueForKeyPath:@"data.abcd"][0] objectForKey:@"id"];
NSString *titleString=[[results valueForKeyPath:@"data.abcd"][0] objectForKey:@"title"];

Also,

NSString *categoryString=dict[@"Category"];
NSString *idString=dict[@"id"];
NSString *titleString=dict[@"title"];

No comments:

Post a Comment