Display each item in an NSDictionary
44,018
Solution 1
Try this code
for(NSString *key in [dict allKeys]) {
NSLog(@"%@",[dict objectForKey:key]);
}
Solution 2
What about
NSLog(@"Dictionary: %@", [myDictionary description]);
Seems to work for me...
Solution 3
This works for me and is very useful for debugging.
NSDictionary *jsonDictionary = [theJSON JSONValue];
NSLog(@"dictionary data %@",jsonDictionary);
Related videos on Youtube
Comments
-
alanvabraham almost 2 years
I am trying to display each item in NSDictionary. I have tried using a for loop but that didn't work.
-
Aniket Thakur almost 6 yearsBetter to add key in NSLog as well. You can do - ` NSLog(@"%@ : %@",key, [dict objectForKey:key]); `
-
Alex Meuer over 5 yearsSince this answer was written, new syntax has become available. You can now do
NSLog(@"%@", dict[key]);
if you prefer..