NSDictionary question
NSDictionary question
- Subject: NSDictionary question
- From: Koen van der Drift <email@hidden>
- Date: Thu, 3 Jul 2003 22:53:45 -0400
Hi,
I have an NSDictionary with the following structure:
<dict>
<key>A</key>
<dict>
<key>code</key>
<string>Aap</string>
...
</dict>
<key>B</key>
<dict>
<key>code</key>
<string>Banaan</string>
...
</dict>
...
</dict>
Now at one point in my code I need to convert a string that is made up
of only the values that correspond to the key 'code' (Aap, Banaan, ...)
to their 'root key' (A, B,...).
What I do now is the following:
1. use a keyEnumerator to iterate over all keys of the NSDictionary.
2. get the object (a dict) from each key and then get the value of the
key 'code'
3. store both the 'value' and the 'key' in a new NSMutableDictionary
using setObject:forKey
4. scan the original string that needs to be converted
5. for each word ('value') look up the corresponding key
6. append the 'key' to a new NSMutableString.
Now I have a converted string.
I have a feeling this can be done much easier (less complicated), but I
haven't been able to figure out how.
Any suggstions/improvements?
thanks,
- Koen.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.