我正在尝试解析以下 JSON 响应:http ://www.breaknews.com/api/v5/items?compact=false 。
这是我解析它的代码:
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);
}
}
}
但是,我收到此错误:
-[__NSCFString objectAtIndex:]:无法识别的选择器发送到实例 0x101810a40
这是为什么 - 我做错了什么?