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?
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.
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.
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.
There are 2 templates and samples: SharedPreferences Singleton that uses String keys. SharedPreferences Single that uses Enum keys.
Take a look at NSUserDefaults
(docs link)
[NSUserDefaults standardUserDefaults]
would be the equivalent of default SharedPreferences
.
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