I am trying to display each item in NSDictionary. I have tried using a for loop but that didn't work.
An NSDictionary will retain it's objects, and copy it's keys.
Creating NSDictionary Objects Using Dictionary Literals In addition to the provided initializers, such as init(objects:forKeys:) , you can create an NSDictionary object using a dictionary literal. In Objective-C, the compiler generates code that makes an underlying call to the init(objects:forKeys:count:) method.
NSDictionary / NSMutableDictionary copies keys, and holds strong references to values. NSMapTable is mutable, without an immutable counterpart. NSMapTable can hold keys and values with weak references, in such a way that entries are removed when either the key or value is deallocated.
An object representing a dynamic collection of key-value pairs, for use instead of a Dictionary variable in cases that require reference semantics.
Try this code
for(NSString *key in [dict allKeys]) { NSLog(@"%@",[dict objectForKey:key]); }
What about
NSLog(@"Dictionary: %@", [myDictionary description]);
Seems to work for me...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With