If application has been reinstalled through xcode all kept settings are cleaned. How to avoid such behaviour?
More detailed: An app has been installed, then I made changes in settings ( settings bundle) and they were stored. After I reinstalled the application through xcode (I didn't remove the app) and all my settings have been cleaned that I made before . I would like to keep my settings after installing application or perhaps there is another way to keep settings of app after installing of it.
Example:
I created Settings Bundle ( File -> New -> File -> Resourses -> Settings bundle)
Changed Root.plist and added there new dict for address value. See below.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>StringsTable</key> <string>Root</string> <key>PreferenceSpecifiers</key> <array> <dict> <key>Type</key> <string>PSGroupSpecifier</string> <key>Title</key> <string>Server</string> </dict> <dict> <key>Type</key> <string>PSTextFieldSpecifier</string> <key>Title</key> <string>Address</string> <key>Key</key> <string>server_address_preference</string> <key>KeyboardType</key> <string>Alphabet</string> <key>IsSecure</key> <false/> <key>AutocapitalizationType</key> <string>None</string> <key>AutocorrectionType</key> <string>No</string> </dict> </array>
To keep the settings of your app use
UserDefaults
, it's the same concept asSharedPreferences
in Android development. So, you can store there user related settings as well as everything else which should remain untouched after updating (Xcode reinstallation) of the app.UserDefaults Apple doc
Example of usage.
Setting value:
Retrieving value: