为什么从ACAccounts加载Twitter帐户需要这么长时间?

时间:2014-07-16 01:36:46

标签: ios twitter acaccount

以下是我用来访问存储在设备上的Twitter帐户的代码;它往往需要大约30秒才能加载到我的设备上(它在模拟器上要快得多)

ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account
                              accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

[account requestAccessToAccountsWithType:accountType
                                 options:nil completion:^(BOOL granted, NSError *error)
 {
     if (granted == YES)
     {
         NSArray *arrayOfAccounts = [account
                                     accountsWithAccountType:accountType];

         if ([arrayOfAccounts count] > 0)
         {
             self.twitterAccount =
             [arrayOfAccounts lastObject];

             UIAlertView* loggedInAlert = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Successfully logged in to Twitter" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
             [loggedInAlert show];
         }
         else {
             NSLog(@"There are not any accounts to post to");
             self.twitterAccount = NULL;
             UIAlertView* noAccountAlert = [[UIAlertView alloc] initWithTitle:@"No Twitter Account Found" message:@"Check the settings of your device and make sure you are logged in to Twitter" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
             [noAccountAlert show];
         }
     } else {
         UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Authentication Failed" message:@"Failed to gain access to Twitter account" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
         [alert show];
     }
 }];

0 个答案:

没有答案