First, Nsuserdefault (preferences, Preference)
Small-scale data, weak business-related data use. Example: The state of a uiswitch.
Two, file (document storage)
file storage includes plist, archive, stream and so on, general structured data or data that needs to be easily queried, will be persisted in plist way. The archive method is suitable for storing data that is not used very often but has a large amount of data, or is expected to be directly object after reading, because archive will serialize the object and its object relationship, so that it takes decode time to read the data, and the decode process can be decompressed, Can also be an object, this can be based on
<NSCoding> the implementation of the specific decision. Stream is the general file storage, commonly used to store pictures ah what, suitable for more often used, but the amount of data is not very large.
1, plist (XML attribute list, essentially XML) Primary storage Nsarray\nsdictionary\nsstring\bool and so on, (storing custom objects requires
archive). plist files typically exist in a sandbox. detailed folder under sandbox
1 "Documents folder folder path:/users/user name/library/developer/coresimulator/devices/emulator udid/data/Documents documents: Only relevant data generated by the program can be saved, and data downloaded from the network cannot be saved, otherwise the shelves will be rejected. Because all content in the documents directory is automatically backed up in icloud. You can store game archives and more.
2 "Library folder /users/User name/library/developer/coresimulator/devices/simulator udid/data/libraryCache folder: Caches the directory, saves data that needs to be persisted when the app runs , can save the data downloaded from the network, and the files you want to use here. The directory is not backed up. Non-critical data that is typically stored in large volumes and does not require backup. If you save the file in the cache, you need to provide the ability to clear the cache. Preferences folder: A dedicated directory of user preferences to save all your app's preferences . It is usually saved using [Nsuserdefault Standarddefault], which isbacked up when itunes synchronizes the device. (Fast storage of some important simple files here, nature is also plist storage, slightly more convenient than plist storage).
3 "tmp folder folder path:/users/user name/library/developer/coresimulator/devices/simulator udid/data/tmptemporary directory, save the temporary data required for the application to run , the reboot will be cleared, and the storage space may be purged by the system. The TMP directory file will not be backed up and cleaned up without the programmer's concern. * Lastpathcomponent The final component from the path, usually the file nameNote: Generally stored in
Documents. (User account, login status token)
2, archive (nscoding)Archive Solution, Nskeyedarchiver\nskeyedunarchiverwrite all data at onceread all data at oncecan not be read in batches, there is a performance problem.
3. Stream
4, etc.
Third, KeyChain
Keychain is an apple-provided storage mechanism with reversible encryption. It is commonly used in a variety of password-saving needs. In addition, because the app is uninstalled as long as the system does not reinstall, the data in the keychain can still be retained, and can be synchronized by icloud feature, we will store the user unique identification string here. So there are sensitive small data that needs to be encrypted and need to be stored in icloud, which is usually placed in Keychain.
Iv. Database-basedThe main is to facilitate the deletion and change to check,
(XMPP) No use.
Several storage methods in the development of B16-ios