使用钥匙串在 xcode 4 中存储用户名和密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8572517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using keychain to store username and password in xcode 4
提问by Popeye
I don't want to use NSUserDefaults
as I have been told it's not a good way to save a username and password.
我不想使用,NSUserDefaults
因为有人告诉我这不是保存用户名和密码的好方法。
So I was going to use a Keychain, but I have never used them before. Can some one please just a give a quick example of one or point me in the direction of an example ? Thanks.
所以我打算使用钥匙扣,但我以前从未使用过它们。有人可以举一个简单的例子或指出一个例子的方向吗?谢谢。
回答by Abizern
I Use the open source SSKeychainwrapper around the the C api used by the keychain.
我在钥匙串使用的 C api 周围使用开源SSKeychain包装器。
It's convenient, easy to use, and works on Mac OS and iOS.
它方便、易于使用,并且适用于 Mac OS 和 iOS。
回答by Ankit Srivastava
This is the best I have found till date... It five a very simple implementation of saving passwords and username to keychain. Please remember to include security framework in your project.
这是迄今为止我发现的最好的......它是将密码和用户名保存到钥匙串的五个非常简单的实现。请记住在您的项目中包含安全框架。
Keep in mind that this doen't work on simulator.
请记住,这在模拟器上不起作用。