Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

roeik

macrumors member
Original poster
Dec 25, 2008
80
0
Hi,

I was wondering what's the best way to store information in an app. I just need to store two values, and I thought the best way to do it is just to use the info.plist.

I am using this code store the the data on the info.plist:

Code:
[[[NSBundle mainBundle] infoDictionary] setValue:[NSNumber numberWithInt:row] forKey: @"exchangeRateCurrencyIndex"] ;

I know that it changes the value while the app is running. But the problem is that the next time I start the app it goes back to the original value the field was set in xcode. (I used both the simulator and the device to debug).

Any ideas why it's doing this?
Thanks.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
You can't modify the Info.plist file. On the device it's inside your application bundle and that is read only. It would ruin the signing of the app if you did change it.

For two values you should use NSUserDefaults.

If you had a lot of data that you wanted to save to a plist file you could write a plist file to your Documents folder.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.