jhd
jhd

Reputation: 1253

When will the data i stored in NSUserDefaults.standardUserDefaults() change?

If I download a new version of my app, will it clear all the data I stored in the NSUserDefaults.standardUserDefaults()? What will it be if I repeat install and delete my app? I down a former version of my app from app store. And i install a new version of my app using Xcode. The data saved in NSUserDefaults.standardUserDefaults() disappeared. Two apps are both release version with a same bundle id. But certificate is different, one is develop, the other is distribution. Is this normal?

Upvotes: 1

Views: 284

Answers (2)

Gihan
Gihan

Reputation: 2536

When you delete your app, It deletes your apps user defaults. However this may not properly work on ios simulator. When you update your application without deleting it first, user defaults wont be changed. But you can delete user default with some code as well.

let appDomain = NSBundle.mainBundle().bundleIdentifier!        
NSUserDefaults.standardUserDefaults().removePersistentDomainForName(appDomain)

Upvotes: 1

Ashish Thakkar
Ashish Thakkar

Reputation: 944

If you update your app then it will not change but if you delete and again install then NSUserDefaults.standardUserDefaults() will changed.

Upvotes: 1

Related Questions