objective-c - 在 iOS 5 中保存 Twitter 帐户?

标签 objective-c ios twitter

我正在使用以下代码来访问用户的 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];
                         }
}];

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

最佳答案

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

关于objective-c - 在 iOS 5 中保存 Twitter 帐户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10777406/

相关文章:

java - Twitter4J 获取最新推文

python - 最大 Twitter ID?

api - Twitter API : what is the difference between `name` and `screen_name` ? 哪一个是 url 用户名?

objective-c - 用户数据存储位置 : in a Sandboxed Mac app container or in Home/Documents?

objective-c - ipad 屏幕录制

ios - 无论我将构建版本或应用程序版本更改为什么,都会出现 ITEMS-4238 "Redundant Binary Upload"错误

ios - Xcode 6.3 在打开 XIB 文件后卡住/挂起

iphone - 如何同时切换tab和pushViewController?

iphone - Objective-C/iOS - 测试是否存在 C 函数?

ios - UIAlert 不适用于 NSNotification