Reputation: 16859
I need to know;
1.) how to save values to a NSDictionary, and in Key-Value pairs. I have the following keys and values to be saved to a single NSDictionary
Key ------ Value
"1" ------- "One"
"2" -------"Two"
"3" -------- "Three" etc..
2.) Later i need to save the above NSDictionary to a NSArray. Is this possible ?
3.) Is there a way to Order the above NSDictionary in Assending order. How can i do this
Upvotes: 1
Views: 358
Reputation: 52575
[NSDictionary dictionaryWithObjectsAndKeys:@"value", @"key", @"value", @"key2", nil]
[dict allKeys]
or [dict allValues]
NSArray
Upvotes: 5
Reputation: 8513
You need to use a NSMutableDictionary
instance. There are methods like :setObject:forKey
After you add dictionary values to an NSMutableArray
instance, you can use the following method to sort them.
[arrayInstance sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
Upvotes: 2