Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS' equivalent of Android's SharedPreferences

I am looking for the iOS equivalent of Android's SharedPreferences. For the iOS people, SharedPreferences is an easy key value lookup available across multiple Activities and Views.

I need to get the user's name, age, and height and store it so that all my iOS views for this app can access it. What is the best way to do this in iOS?

like image 425
Alexis Avatar asked Nov 12 '12 23:11

Alexis


People also ask

Is SQLite better than SharedPreferences?

It stores structured data as a database. The data can be queried and hence ,this makes it possible to search database. Reading data from sqlite database is slower and more expensive then shared preferences. SQLite database is useful for just about anything and very flexible.

What is shared preferences in Swift?

Shared preferences is a light weight data storage option provided by Android. It allow us to store and retrieve small amounts of primitive data as key/value pairs in a file on the device.

Can I save array list in SharedPreferences?

We can store data in the form of key and value pairs using Shared Preferences. In this article, we will take a look at How to Save Array List to SharedPreferences in Android using Kotlin.

Is SharedPreferences Singleton?

There are 2 templates and samples: SharedPreferences Singleton that uses String keys. SharedPreferences Single that uses Enum keys.


1 Answers

Take a look at NSUserDefaults (docs link)

[NSUserDefaults standardUserDefaults] would be the equivalent of default SharedPreferences.

like image 109
devunwired Avatar answered Oct 24 '22 03:10

devunwired