The reason you see this is because avatars not an NSDictionary , but an NSArray .
I can say because:
- the exception you get indicates that
__NSCFArray (i.e. NSArray ) does not recognize the objectForKey: selector objectForKey: when registering avatars it also prints a bracket ( . The array is registered as follows:
(first element, second element, ...)
while the dictionary is registered this way:
{ firstKey = value, secondKey = value, … }
You can fix it as follows:
NSArray *avatars = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil]; NSLog(@"response:::%@", avatars); if(avatars){ NSDictionary *avatar = [avatars objectAtIndex:0];
Also note that the key for avatarImage .
source share