Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - how to save user settings from application?

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.

like image 308
Ilya Suzdalnitski Avatar asked Apr 25 '09 17:04

Ilya Suzdalnitski


People also ask

How do I save user preferences in Swift?

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.

How do I see app permissions on iPhone?

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.

What should I store in user defaults?

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.


1 Answers

NSUserDefaults is the best place for settings like this.

like image 80
Marc Charbonneau Avatar answered Oct 15 '22 22:10

Marc Charbonneau