简体   繁体   English

如何在iPhone应用程序上存储多个帐户的用户登录详细信息(用户,密码)

[英]How to store user Login details(user, pass) for multiple accounts on iPhone app

I have an iPhone application that requires the user to login(username, password). 我有一个iPhone应用程序,要求用户登录(用户名,密码)。 I currently store the credentials of the last succesful login and fill the textfields the next time the user launches the app. 我目前存储上一次成功登录的凭据,并在用户下次启动应用程序时填充文本字段。

Alot of the times though the user may have more than one account and I now need to implement something to store login credentials for more accounts. 尽管很多时候用户可能拥有多个帐户,但我现在需要实现一些功能来存储更多帐户的登录凭据。

How would you suggest that I do that? 您如何建议我这样做? I looked around but I couldn't find anything related to this. 我环顾四周,但找不到与此相关的任何内容。

NSUserDefaults or Storing into sqllite or Storing into a plist are on of the ways of storing persistent data. NSUserDefaults或存储到sqllite或存储到plist是存储持久性数据的方法之一。 But they are not secure. 但是它们并不安全。 I will recommend Key Chain Access for storing secure data. 我将建议使用钥匙串访问来存储安全数据。

This link provides a apple sample code which uses key chain Access 该链接提供了一个使用钥匙串访问的苹果示例代码

http://developer.apple.com/library/ios/#samplecode/GenericKeychain/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007797-Intro-DontLinkElementID_2 http://developer.apple.com/library/ios/#samplecode/GenericKeychain/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007797-Intro-DontLinkElementID_2

But one disadvantage is you cant test this in simulator it works only on device i think. 但是一个缺点是您不能在模拟器中测试它,它只能在我认为的设备上工作。

You can also add multiple items to the keychain. 您还可以将多个项目添加到钥匙串。

Look NSUserDefaults at the documentation . 文档中查看NSUserDefaults

Maybe this tuto can help you : http://icodeblog.com/2008/10/03/iphone-programming-tutorial-savingretrieving-data-using-nsuserdefaults/ 也许这个教程可以帮助您: http ://icodeblog.com/2008/10/03/iphone-programming-tutorial-savingretrieving-data-using-nsuserdefaults/

尝试使用CoreData ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM