使用NSUserDefaults存储许多值会导致问题? [英] Using NSUserDefaults to store many values will cause problems?
问题描述
我创建了一个应用程序,将使用用户名,密码登录,并允许用户从服务下载文件。在我的应用程序中,一旦用户在应用程序中登录,就必须保留少量数据。
I have created an application which will login using username, password and allows the user to download the files from serve. In my application I have to persist few datas once the user have login in the application.
持久存储用户名,密码,用户下载列表,订阅计划等数据。数据可以通过NSUserDefaults,Plist等等持久化在应用程序中。但是我感觉容易使用NSUserDefaults存储和检索值。因为我需要使用许多视图控制器中的值,我更喜欢 NSUserDefaults
。
Persisting data like Username, Password, user downloaded list , subscribed plans,etc. The data can be persisted in application either by NSUserDefaults,Plist , etc. But I feel easy to store and retrieve the values using NSUserDefaults. As I need to use the values in many view controllers, I prefer NSUserDefaults
.
这是最好的做法吗?使用过多的 NSUserDefaults
会导致陷阱?
Is this the best practice ? Using too much NSUserDefaults
will result in a trap ?
Tell me is there other way to persist the data and retrieve it easily in cocoa-touch ?
推荐答案
你可以使用这个方法来保存数据,使用 NSUserDefaults
存储用户数据。
You can use NSUserDefaults
for storing user data.
但对于高度敏感的数据,如 code>和
密码
我更喜欢钥匙串
来存储它们。
But for highly sensitive data like Username
and Password
I prefer keychain
to store them.
请检查以下链接以了解钥匙串保存:
Please check these links for Keychain saving:
- Simple iphone keychain access
- saving email password to keychain in ios
- howto use keychain in iphone sdk
这篇关于使用NSUserDefaults存储许多值会导致问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!