iphoneobjective-cipadnsmutabledictionary

Get NSMutableDictionary Keys as Strings?


I have an NSMutableDictionary with 10 objects each with a key of course, the keys are all words and this is in a plist.

So I have entered these words into the plist in a specific order:

e.g.

hello
goodbye
please
thankyou

How can I get these keys as an array of strings? I have tried allKeys but for some reason it puts them all out of order and words with spaces in are given quotation marks (I've seen this from logging the array).


Solution

  • NSMutableDictionary doesn't keep data in any specific order. Instead, you should use an NSArray. That way you will have the words in your desired order and use them to access the dictionary to retrieve the dictionary's data.