我试图从字典中获取特定键的值,但我得到一个“[__NSCFArray objectForKey:]: unrecognized selector sent to instance”
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSDictionary *avatars = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
NSLog(@"response:::%@", avatars);
if(avatars){
NSDictionary *avatarimage = [avatars objectForKey:@"- image"];
NSString *name = [avatars objectForKey:@"name"];
}
}
我 NSLog 我的头像字典,我的结果是:
(
{
"created_at" = "2013-06-06T11:37:48Z";
id = 7;
image = {
thumb = {
url = "/uploads/avatar/image/7/thumb_304004-1920x1080.jpg";
};
url = "/uploads/avatar/image/7/304004-1920x1080.jpg";
};
name = Drogba;
"updated_at" = "2013-06-06T11:37:48Z";
}
)