NSUserDefaults and Update an application from app Store - iphone

In my app I'm using NSUserDefaults to store user data, when upgrading to a new version from App Store will those values be saved or deleted/ rebooted?
(for example: [prefs setInteger:_numberOfTimesAppOpened forKey:#"openApp"]; if before the upgrade the value is 70 after the upgrade will the value be 70/ 0/ or non existent?)
in case these parameters are deleted what is the right approach to save user data so it will be saved even when upgrading the application?
another question is if there is a way to store information on the device so if the user delete the app and then re-install it his previous data/ profile can be set?

Everything that is stored in UserDefaults will be still there after an update. They are persisting. User defaults will get deleted when the app is removed from the device by the user.
And there is no way to store if an app was installed already once. At least not on the device.

Related

How can i come to know app is not installed first time on a device iPhone

I want to store some value when app is installed first time.
So when user delete and re install that app . read that value and take actions accordingly.
Is there any way ?
Scenario:
App installed first time store value somewhere.
User deletes app from iPhone.
Re install app again.
Read that stored value. ?
Is this possible ?
To achieve what you want, You can directly refer Keychain Data from Apple Documentation.
use the Keychain to store your data, because the Keychain items are not deleted even if the app is Uninstalled or removed.
This Api will help a lot Link, have a look

Persist SQLite Data upon application uninstall

We are storing a unique identifier for the mobile device in an SQLite database, to be used for licencing purposes. The problem is that if a user removes the application then reinstalls it again, the SQLite database is gone along with our stored variable.
How to prevent removing the databse upon application installation, so that we can reuse the database if the application was reinstalled again
Thanks
You can approach this by sending the information to a server side, you can't store any data out side the application sandbox.
You could:
Store the key on your own server
Store the key in the device's keychain. Notice that you won't be able to remove the key from the user's keychain after the app has been removed from their device. More info about the keychain here: https://developer.apple.com/library/ios/#documentation/Security/Reference/keychainservices/Reference/reference.html
In the program you can create a copy of the SQLite database. Simply drag and release the database into the program resources.

Does a TestFlight upgrade break Core Data schemes in an app?

I've got an app that I'd like to send to beta testers using TestFlight.
We won't be changing the Core Data model, but I'm curious about two things:
When I send out an updated beta, is there any risk that the Core Data will be corrupted with the update?
When the app goes to the App Store, will our beta testers have to start fresh from the App Store version, or will their Core Data still appear in the App Store version?
The user's data is stored in their own documents directory. If you haven't changed the scheme (or if you have and you have a proper migration set up) then just updating the app will not affect their own data - unless they delete and install the application again.
If you haven't changed the bundle identifier - and they don't delete and re-install their app - the data will still exist in the Document directory.

Iphone persistant preferences after app delete

I want to store a date string in the iphone device, but not in the application context, because if a user deletes the app then that value is deleted too.
Is this possible?
Store it in the keychain. Keychain data is not deleted when the app is.
A possible solution is to store all the information on a server. You could use rails, php, or any other server framework to do this. Also, there's a new service that's trying to make it so you don't have to do any server coding at all: http://www.parse.com
If the application gets deleted on iPhone, all its related files are also deleted. Including files, SQLite databases and preferences.
If you want preference to persist after deletion, you will need a server and allow the user to store that information there (in the cloud).

Removing keychain data on uninstall

Does anyone know of a non-programatic method of removing data stored in the keychain when the application is deleted from the device?
I've read on several threads on SO that the data will persist even if the application is uninstalled and my experience confirms this is true.
However this seems contrary to what is specified in Apple's iOS Application Programing Guide: "The keychain data for an application is stored outside of the application sandbox. If an application is uninstalled, that data is automatically removed".
You could wipe the iPhone by using Erase all Contents and Settings.