Difference between Keychain and NSUserDefault?

廉价感情. 提交于 2019-11-29 01:53:39
Aravindhan

A keychain is an encrypted container that holds passwords for multiple applications and secure services. Apple Inc. uses keychains as password management system in Mac OS and iOS.

NSUserDefaults Provides a way for application behavior customization based on user preferences. Belongs to the Foundation framework for Cocoa and Cocoa Touch.

I got this from Tag Information of NSUserdefaults and keychain

Addition: When we saved userName and Password. and Remove app from device.

In Keychain: UserName and Password still is there.

In NSUserDefaults: UserName and Password also remove from device with your app.

Try to avoid saving data locally as much as possible.

Keychain- Keychain is safe & encrypted way to save small storage data like username, password etc. Beware keychain data can accessible from jailbroken devices . You can get Apple sample code from here.

Keychain Sharing- Enabling keychain sharing allows your app to share passwords in the keychain with other apps developed by your team. Suppose we created two apps where users can log into the same account. It would be nice to have ability to share the login information between these apps. This way the user will only need to log in once in one of the apps.

UserDefaults An interface to the user's defaults database, where you store key-value pairs persistently across invocations of your app on a given device. UserDefaults are not secure way to save private data. UserDefaults are stored as plist locally, Anyone can track in ./Library/Preferences/com.mycompany.MyAppName.plist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!