Storing information on info.plist

Discussion in 'iOS Programming' started by roeik, Nov 1, 2009.

  1. macrumors member

    Joined:
    Dec 25, 2008
    #1
    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.
     
  2. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    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.
     

Share This Page