views:

205

answers:

2

I have to save some config parameters with values in iPhone. I need to edit values at app runtime. I see there are two ways to implement this:
1. Use pList file
2. Create new XML file.
What is the best approach to implement this? Should I use existing Info.pList file?

Thanks

+2  A: 

The best solution is probably using a dictionary and saving that to a property list, it's incredibly easy. Do not use the existing Info.plist, you don't want to polute it with your own settings.

Here's a quick exaple on how to save a dictionary to a property list and load it:
http://codersjunto.com/wp/?p=16&cpage=1

Yannick Compernol
What about binary format? Is it more faster?
Brij
Yannick Compernol
Do not use the binary format unless you file is over 10k or so. Any gain you would have is not worth the annoyance of conversion and lack of ability to modify in a text editor.
Kendall Helmstetter Gelner
+1  A: 

An Info.plist file is XML, it is directly readable from a file to a NSDictionary or NSArray. You can also choose the file format as XML or a binary format, the binary format is a lot smaller and can load faster especially over a network.

zaph
Can you give sample for binary format?
Brij
Use the application "Property List Editor" found in /Developer/Application/Utilities. Open a plist file, select "Save As:" and select "Binary Property List" from the "FIle Format" popup list. I found that loading a plist over the Internet was several times faster.
zaph