12

I have a little question regarding NSUserDefaults. When the application is deleted, what happens to the values stored in the NSUserDefaults? Do they get deleted as well?

When I remove a app and reinstall it from the app store the previous NSUserDefaults values are loaded?

Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
user3568907
  • 337
  • 1
  • 3
  • 5
  • 5
    When you delete app then nsuserdefault will be deleted. so when reinstall it you can not get that userdefault. – ChintaN -Maddy- Ramani Apr 24 '14 at 12:59
  • Do you develop the app yourself (the answer seems to be 'no')? Because deleting the app should clear NSUserDefaults. Perhaps the settings are restored from iCloud? – Rafe Apr 24 '14 at 13:01
  • possible duplicate of [Are values stored in NSUserDefaults removed when the app that put them there is uninstalled?](http://stackoverflow.com/questions/7520800/are-values-stored-in-nsuserdefaults-removed-when-the-app-that-put-them-there-is) – zoul Apr 24 '14 at 13:11
  • Cmon - one google search would have done it. Anyways, +1 for Chinttu RoxeN Ramani. – NDY Apr 24 '14 at 13:13
  • I have enabled iCloud for my app.so will this be a problem. – user3568907 Apr 24 '14 at 13:20

1 Answers1

16

When an app is deleted from the device all local data associated with the app will be deleted too. This includes NSUserDefaults. However any data stored at an online service won't. For example, iCloud. The app will just fetch the data again if requested to do so by the user / developer.

Edit

As per mAu's comment below - this includes keychain data, which won't be deleted either.

Robert J. Clegg
  • 7,231
  • 9
  • 47
  • 99