我从https://twitter.com/statuses/public_timeline.json获取 JSON 对象
所以,我的代码是下一个:
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"https://twitter.com/statuses/public_timeline.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
students = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
for(NSDictionary *item in students) {
NSLog(@"Message: %@", [item objectForKey:@"message"]);
}
}
所以,我得到下一个错误:
2013-01-23 21:42:02.672 students[94907:11603] -[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x7471580
2013-01-23 21:42:02.681 students[94907:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x7471580'