How to choose account and service values for SSKeychain

China☆狼群 提交于 2019-11-30 06:32:34

问题


I'm thinking of using SSKeychain for storing a password in an iOS app, but I'm not sure if I need some specific value for the account and service, or if it will be OK with just arbitrary ones. Is there a common practice?


回答1:


The Service should be a unique string for your App, possibly use the iOS Bundle Identifier as the Service or the name/URL of your Application or Web App or whatever you are setting the Password for. This should ideally be constant throughout your Application but there is no specific preference. I personally prefer to set it to the Web Service URL but that is my preference.

The account bit is in essence similar to a Username field on any application. That's so you can store multiple passwords for the same service but for different accounts. If you are working on an application which doesn't have a username field then you could set it to 'user' or something arbitrary but remains constant throughout the application and in future versions.

So if I am storing the password for joebloggs with password 'test' for the acme.com service, here is how I'd store it:

NSString *password = [SSKeychain setPassword:@"test" forService:@"acme.com" account:@"joebloggs"];

SSKeychain is so easy and fantastic to use. Definitely a good choice!



来源:https://stackoverflow.com/questions/7663948/how-to-choose-account-and-service-values-for-sskeychain

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