Advise on how to updae NSMutableDictionary

Discussion in 'iOS Programming' started by mrl72, Jan 11, 2011.

  1. macrumors regular

    Joined:
    Apr 20, 2008
    #1
    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:

    Code:
    	<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
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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?
     
  3. mrl72, Jan 11, 2011
    Last edited: Jan 11, 2011

    thread starter macrumors regular

    Joined:
    Apr 20, 2008
    #3
    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 :)
     

Share This Page