You will see two folder, 'Caches' and 'Preferences', the UserDefaults plist file is stored inside the 'Preferences' folder. userDomainMask, true)īuild and run the app in Simulator, then open Finder and press command + shift + G, paste in the library path and click 'Go' to navigate to the Library folder. Let library_path = NSSearchPathForDirectoriesInDomains(.libraryDirectory. We can take a peek into the Library folder like this : ("", forKey: "homepage") The UserDefaults plist is saved in the Library folder inside the app folder ( Read more on app folder structure here). When you store data in UserDefaults, the data format is similar to ist as well. There is usually an ist file created for you when you start new iOS project : plist file before, plist is short for property list. what is a property list? □ What does "A default object must be a property list" means? If you want to store any other type of object, you should typically archive it to create an instance of NSData. What type of data can we store in UserDefaults?Ī default object must be a property list-that is, an instance of (or for collections, a combination of instances of) NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary. How to decide which approach to use for saving data? □Īs per Apple Documentation, UserDefaults isĪn interface to the user’s defaults database, where you store key-value pairs persistently across launches of your app. UserDefaults, Keychain and Core Data are some of the most popular ways to persist data (so that the data is still there the next time user launch your app after quitting). There are many ways to store data locally in iOS app.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |