In ios, If the user backups an application and restores the backup, will the data in NSUserDefault will get persisted? If yes, How to avoid it.
The NSUserDefaults are stored in the backup and therefore will be restored as well.
Related
My app uses Core Data to store multiple entries, and NSUserDefaults to store a value. If I publish an update to the app store, will it erase that info? I have not adjusted the code for the Core Data; however, I added code for a nil/non-existent case for the NSUserDefaults
No, updating an app does not erase the app's data, even if the app uses Core Data or NSUserDefaults. Deleting and reinstalling an app removes app data stored on the device, but doesn't touch any cloud data the app may have stored.
I understand that NSUserDefaults data is unencrypted and should not be used to store sensitive information. I'm trying to understand how easily someone could get at that information. This thread shows that it's just a plain file on the iphone filesystem.
Will this file be transferred to the user's computer during an iPhone sync (if app sync is enabled)? If so, then it'd be extremely easy for anyone to read information stored in NSUserDefaults
Yes the file will be synced during a backup and it will be just a regular file unless the user has enabled encrypted backups in iTunes, in which case the entire backup contents are encrypted.
I tried this out. Turns out that it's not the same plist file that you can see in the simulator, but it is there in the backup directory after a sync. You can see the contents by running strings.
All the more reason to use the keychain!
Would the value of NSUserDefaults lost after upgrade the app?
If I delete the app and reinstall it ,and then restore data from Itunes backup, would the value of NSUserDefaults lost?
You don't lose the value of NSUserDefaults when you upgrade the app.
When you delete and reinstall the app, though, you reset all the NSUserDefaults keys, so you can lose data (i.e. your score, etc).
Restoring from backup doesn't lose the NSUserDefaults value, due you've stored the value in iTunes and iTunes is giving you back again that value.
iCloud is the better solution unless you have some reason for not using it, and has the advantage of synchronizing multiple installations by the same user should you so desire.
I'm using [NSUserDefaults standardUserDefaults] for storing application settings.
My questions are:
do those settings are removed on app deletion?
are they kept after an application update (through the
AppStore)?
Because I'm using it to store a password and don't want my users to reset them at each update. Also, I'd like that the only way to reset the password would be to remove the app and re-install it.
Is NSUserDefault the right choice?
Thanks,
Jérémy
Yes, they are removed on app deletion and yes they are kept when an application is updated.
However, you're not advised to store sensitive data in the NSUserDefaults, instead I would look at using the Keychain.
I use NSUserDefaults in my app to allow additional access to my app for my colleagues. They just have to enter the code word in settings and the app is fully opened.
to the point each time I update the app they have to re-enter the code word, so I would say from experience that they are not kept after updates. The values need to be re-entered.
I have an app that lets user record their own audio.
By now I'm saving those files into Documents directory.
My question is: if I will release a new version of that app, will user recorded files get deleted?
Is there a better place to store user generated audio files?
Should I use NSUserDefaults for data that stay even after app upgrade?
thx
NSUserDefaults is used for storing settings (objects of Key-Value Coding compliant classes)
Other data such files you should store in Documents folder, wich survive between updates (if you don't delete it yourself, of course :)
Both the Documents directory and NSUserDefaults survive application updates. Choosing which to use depends on the kind of your data.
if I will release a new version of that app, will user recorded files get deleted?
No.
Is there a better place to store user generated audio files?
No.
Should I use NSUserDefaults for data that stay even after app upgrade?
Only if your data is small.