今天是个好日子!我只想问我在做什么有什么问题。我正在处理这个两天,但我仍然无法做到。它说“无法识别的选择器发送到实例 0x748b800”。我正在做的是解析一个 json 返回值。以下是示例 json 返回值:
{
"data": [
{
"name": "John Patola",
"id": "123444432"
},
{
"name": "Joshua Valdez",
"id": "22234567778"
}
]
}
我想将它们存储在一个名为
NSArray *storage
. 以下是我的代码:
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[self.rData appendData:data];
}
-(void)connection: (NSURLConnection *)connection didFailWithError:(NSError *)error{
[rData release];
[connection release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSString *myVar = [[[NSString alloc] initWithData:rData encoding:NSUTF8StringEncoding] autorelease];
NSArray *storage =[[(NSDictionary *)myVar objectForKey:@"data"]retain]; // this line seems to be the error
NSLog(@"%i", [storage count]);
当我运行此代码时,我收到一个错误“无法识别的选择器发送到实例 0x748b800”。你认为我标记的那行真的会出错吗?我该如何解决?提前谢谢你的帮助。;-)