Thursday, July 26, 2007

Saving data using NSDictionaries

Okay, I had a blog viewer inquire about this problem. They were wanting to save information about people in a single XML file but didn't know how to do it. 

If you want to save information about people, the easiest way to do that is by using nested dictionaries where a single root dictionary contains dictionaries with your data. 

When you store all your dictionaries in a root dictionary, you can just write the root dictionary to file and and you will get an XML file representation of you data. 

I have a demonstration app up on the server, you just can't find it from the first page. 

Here is the link to the dictionary example to demonstrate how you do this. 
maccoder.server.googlepages.com/DictionaryExample.zip
Make sure you build it in XCode first before you run it. The current built file doesn't reflect a change I made in code to keep it from locking up your computer. 

I hope this helps!
Happy coding! :-)

No comments: