i have a NSDictionary
which looks like:
{ "Item1" = 2.4; "Item2" = 5.5; "Item3" = 15.6; }
To use this NSDictionary
Items in a Table View i have to transfer it to a NSArray
, am i right?
So i try:
NSDictionary *dict = [myDict objectForKey:@"items"]; for (id item in dict) { [_myArray addObject:[dict objectForKey:item]]; }
But _myArray keeps empty? What am i doing wrong?
An object representing a static collection of key-value pairs, for use instead of a Dictionary constant in cases that require reference semantics.
The main difference is that NSArray is for an ordered collection and NSSet is for an unordered collection. There are several articles out there that talk about the difference in speed between the two, like this one. If you're iterating through an unordered collection, NSSet is great.
Main Difference is:NSMutableDictionary is derived from NSDictionary, it has all the methods of NSDictionary. NSMutableDictionary is mutable( can be modified) but NSDictionary is immutable (can not be modified).
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.
NSArray * values = [dictionary allValues];
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