在iOS 5中保存Twitter帐户?

Sno*_*man 4 twitter objective-c ios

我正在使用以下代码访问用户的Twitter帐户:

ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountType *twitterAccountType = 
[store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

//  Request access from the user for access to his Twitter accounts
[store requestAccessToAccountsWithType:twitterAccountType 
                 withCompletionHandler:^(BOOL granted, NSError *error) {
                     if (!granted) {
                         NSLog(@"User rejected access to his account.");
                     } 
                     else {
                         NSArray *arrayOfAccounts = [store accountsWithAccountType:twitterAccountType];
                         if ([arrayOfAccounts count] > 0)  {
                             ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
                         }
}];
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何在应用会话之间保存用户的帐户?对于当前会话,我可以将其存储在实例变量中,但如果用户退出应用程序并返回,我该如何获得该帐户?我有电话[store requestAccessToAccountsWithType:twitterAccountType...]吗?每次?

Hor*_*ain 8

您可以保存TWAccount.identifier,然后使用[ACAccountStore accountWithIdentifier]以便稍后检索该帐户.