-1
在JSONkit.h
使用NSDictionary
存在問題。什麼是正確的方式來使用它?JSONKit NSDictionary
JSON:
[{"id":"1100","name":"John Stuart"}]
代碼:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSDictionary *jsonData = [responseData objectFromJSONData];
NSString *name = [jsonData objectForKey:@"name"];
NSLog(@"Name: %@", name);
}
錯誤:
** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[JKArray objectForKey:]: unrecognized selector sent to instance 0x84b9b30'
您從示例某處複製的第一行是錯誤的。最外層的JSON結構是由周圍的[]'字符表示的「數組」。 – 2013-02-13 02:32:39