Cache the email address and password in google Doc API in iPhone App
I am using the Google Document Api to upload my Document to my google account through my iPhone App but the problem is that every time i use the App Google Api ask for email address and password i want to cache my email address and password so that is don't ask me to re-enter it again is th开发者_如何学编程ere any way to do this?
For something this simple, you can use NSUserDefaults. You can do this anywhere you need to:
To save your info:
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setString:@"GDocsPW"];
[userDefaults setString:@"GDocsUserName"];
[userDefaults synchronize];
To retrieve the info:
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
self.yourGDocsPassword = [userDefaults stringForKey:@"GDocsPW"];
self.yourGDocsUsername = [userDefaults stringForKey:@"GDocsUserName"];
精彩评论