I am trying to parse the following JSON response: http://www.breakingnews.com/api/v5/items?compact=false.
Here is my code to parse it:
NSError* error = nil;
NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.breakingnews.com/api/v5/items?compact=false"] options:NSDataReadingUncached error:&error];
if (error) {
NSLog(@"%@", [error localizedDescription]);
} else {
NSError *e = nil;
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData: data options:kNilOptions error: &e];
if (!jsonArray) {
NSLog(@"Error parsing JSON: %@", e);
} else {
for(NSArray* item in jsonArray) {
NSLog(@"Item: %@", item);
}
}
}
However, I'm getting this error:
-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x101810a40
Why is this - what am I doing wrong?