Storing information on info.plist

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

  1. roeik macrumors member

    Dec 25, 2008

    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:

    [[[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?
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    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