Advertise here

Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

NSUserDefaults Data Lost After Update

Hi, i am using nsuserdefaults to save highscores in my app. But after the update of game, all data is lost. Why? Whats the solution? thank you


  • Sarabyte_StudiosSarabyte_Studios Posts: 7
    edited April 2013
    You may have changed the key, for example it may have been @highScore, and you may have to changed to something else such as @high_Score. This would cause it to load the data for the wrong key. To fix it, you would have to change it back to the original key.
  • kashif789uskashif789us Posts: 5 Noob
    No i havent :(
  • Okay, I'm not sure if this will affect the NSUserDefaults but maybe you changed the Bundle ID?
  • jitendrajitendra Posts: 59 @
    edited April 2013
    NSMutableArray* array = [NSMutableArray arrayWithArray: [[NSUserDefaults standardUserDefaults] arrayForKey: @array_key]];
    //update saved array
    [[NSUserDefaults standardUserDefaults] setValue: saved_array forKey: @array_key];

    in that code save your result to nsmutable array then store it into nsuser default. when you updating the app add the highscore into array. and this value store it into nsuserdefault.
    Post edited by jitendra on
  • kashif789uskashif789us Posts: 5 Noob
    no, there is no change in bundle id, i think perhaps i am overwriting the values somewhere.
Sign In or Register to comment.