更新时间:2023-11-26 20:34:46
在存储会话方面,我假设用户名和密码就足够了。
In terms of storing the session, I assume username and password is enough.
如果您使用的话,可以在NSUserDefaults或CoreData中存储用户名。使用钥匙串***存储密码。 SSKeychain 可以轻松完成此任务。
You could store the username as you wish in NSUserDefaults or CoreData if you are using it. Storing a password is best using the keychain. SSKeychain makes it easy to do this.
[SSKeychain setPassword:password forService:myAppName account:userName]
您可以存储他们在内存中登录的事实,但是在应用程序重新启动时检查:
You could store the fact they are logged in in-memory, but on app relaunch check by:
NSString *password = [SSKeychain passwordForService:myAppName account:userName];
if (password != nil)
{
// Logged in
}
如果用户退出,轻松删除钥匙串中的密码
If the user logs out, easy as deleting the password from the keychain by
[SSKeychain deletePasswordForService:myAppName account:userName]