Home » Android » objective c – iOS' equivalent of Android's SharedPreferences

objective c – iOS' equivalent of Android's SharedPreferences

Posted by: admin June 15, 2020 Leave a comment

Questions:

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?

How to&Answers:

Take a look at NSUserDefaults (docs link)

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

Answer:

You can store settings bundles. Here is a link to the docs:
http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/UserDefaults/Preferences/Preferences.html