This is the code I am using to get string coming through a SBJson parsing:
NSMutableArray *abc=[jsonData valueForKey:@"items"];
NSString *imgStr=(NSString *)[abc valueForKey:@"image"];
NSLog(@"%@",imgStr);
here abc is NSMutableArray
and the exception it is throwing is
> -[__NSArrayI stringByReplacingOccurrencesOfString:withString:]: unrecognized selector sent to instance
In the first line you declare
abcto be anNSMutableArrayIn the second line you attempt to access it as an
NSDictionary.In your case (and I am guessing here), I expect you have an array of items, and each item is a dictionary with an “image” key.
So to get your first item you might use
Then you can extract your image from that:
NSString *imgStr=(NSString *)[firstItem valueForKey:@”image”];11 see comment from @Stig