PDA

View Full Version : Advise on how to updae NSMutableDictionary




mrl72
Jan 11, 2011, 07:54 AM
I am retrieving a list of my friends from Facebook and storing them in a plist, however I cannot completely understand how best to do this. I have the writing to plist fine, in fact I am going through the results returned from FB (an array) and adding the results to a NSMutableDictionary and then writing the results to a plist. Here's what's happening, or what I don't understand and could do with some guidance on.

Results:


<dict>
<key>first_name</key>
<string>John</string>
<key>last_name</key>
<string>Doe</string>
<key>name</key>
<string>John Doe</string>
<key>pic_big</key>
<string>http://blahblah.jpg</string>
<key>uid</key>
<real>123456</real>
</dict>
<dict>
<key>first_name</key>
<string>Jane</string>
<key>last_name</key>
<string>Doe</string>
<key>name</key>
<string>Jane Doe</string>
<key>pic_big</key>
<string>http://blahblah.jpg</string>
<key>uid</key>
<real>2345</real>
</dict>


So questions:

1. How can I say search the array above and pull out someone with uid=2345?

2. Having done #2 above, I then need to update the array for uid=2345 changing, say, the pic_big string to something else.

3. Write back to plist.

Is something like this possible, or am I barking up the wrong tree? :)

Cheers



robbieduncan
Jan 11, 2011, 08:15 AM
If you want a collection indexed on UID why don't you store the data as a dictionary of dictionaries with the outer dictionary using UID as keys?

mrl72
Jan 11, 2011, 08:34 AM
Yeap that's exactly what I would like to do but not quite sure how the dictionary works either. So a dictionary is the best way?

Cheers.

Edit: Never mind, read the help and figured it out :)