What is the easiest way to save a couple of variables in an iPhone application in a long-term memory?
I have an application that works with different sqlite databases and I want after exiting from an application to save last active database name in order to open last database when user enters an application again.
It's a little bit no convenient to create for this purpose a special database and store those values in it, because I have only a couple of variables to store.
What is the easiest way to store those variables?
Thank you in advance.
You may want to look into NSUserDefaults and keyChain if you need to store a password. 'NSUserDefaults' are perfect just as others suggested. They are a simple and easy way to set permanent default values for simple data types.
Go to Settings > Privacy & Security, then tap App Privacy Report. The App Privacy Report shows you how apps are using the permissions you granted them and shows you their network activity.
You can use UserDefaults to store any basic data type for as long as the app is installed. You can write basic types such as Bool , Float , Double , Int , String , or URL , but you can also write more complex types such as arrays, dictionaries and Date – and even Data values.
NSUserDefaults is the best place for settings like this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With