Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
479 views
in Technique[技术] by (71.8m points)

iphone - How to choose account and service values for SSKeychain

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...