If I have some saving in NSUserDefaults whilst debugging my app, and then I submit it to the store, will the stuff be stored on that too? or does it get cleared when saved for a new distribution?
Cheers
Sam
The code will be there, but the things that you saved will not package with the app.
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 am using NSUserDefaults in my app and I am unclear about how NSUserDefaults behave with regard to multi-tasking. Currently I create my NSUserDefaults from a settings.plist file in my project the first time the app is installed and launched. Successive app launches rely solely on NSUserDefaults.
Question: do NSUserDefaults persist even if the user discards the app icon from the multi-tasking dock. Note here I do not mean they have de-installed the app. Just removed it from multi-tasking.
Thanks,
Doug
NSUserDefaults will persist in that case as long as they have been synchronized using the synchronize method.
NSUserDefaults data does persist after the app has been removed from multitasking.
See link
https://stackoverflow.com/a/4771560/716216
My [NSUserDefaults standardUserDefaults] are not being saved. Everytime I close the app and start it again, it reverts back. I don't have my iOS device handy so I am not sure if this will happen on device, but none of the other apps are doing this in simulator which leads me to believe there's something wrong with my code. I don't know what part of code I should include here, it's just simple add/modify keys in NSUserDefaults and as I said it runs fine during the app, but not after i restart it...
I know I can call synchronize but Apple advices against it and says I should only call it if it's a must... so.
What could be going wrong?
Your process is possibly terminated improperly so that NSUserDefaults do not have a chance to be stored. See also this and mostly this.
The suggestion in the second post I link to is to call synchronize in applicationDidEnterBackground:
Keep also in mind that terminating your app by stopping it in Xcode most often does not save user defaults.
Are you restarting from Xcode / debugger? Try sending the app to background with the Home button first. I think the framework synchronizes automatically then.
I could not understand about the way, you are accessing the NSUserDefault, The static function you used sharedDefaults with NSUserDefault does'nt exist in Apple Documentation
Use As below to access NSUserDefault
[NSUserDefaults standardUserDefaults];
For more read the blog post for using of NSUserDefault.
iPhone Programming Tutorial – Saving/Retrieving Data Using NSUserDefaults
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.