iOS推特框架:如何获取(在回调中)用于推特的最后一个推特帐户?

iOS推特框架:如何获取(在回调中)用于推特的最后一个推特帐户?,ios,twitter,callback,account,Ios,Twitter,Callback,Account,一旦用户发了推特,我需要区分他使用的推特帐户。让我们考虑用户在电话上配置了1个或多个帐户。 我需要知道这一点后,推是成功的,所以适当的地方将是回调。我尝试使用ACAccountStore获取帐户,但它提供了一个数组,其中包含在手机上设置的所有帐户,而没有关于上次使用的帐户的线索(甚至连数组的顺序都没有) 有人知道tweetcomposeviewcontroller是否记得这个帐户,以及如何获取它吗 谢谢 我的代码: if ([TWTweetComposeViewController canSen

一旦用户发了推特,我需要区分他使用的推特帐户。让我们考虑用户在电话上配置了1个或多个帐户。 我需要知道这一点后,推是成功的,所以适当的地方将是回调。我尝试使用ACAccountStore获取帐户,但它提供了一个数组,其中包含在手机上设置的所有帐户,而没有关于上次使用的帐户的线索(甚至连数组的顺序都没有)

有人知道tweetcomposeviewcontroller是否记得这个帐户,以及如何获取它吗

谢谢

我的代码:

if ([TWTweetComposeViewController canSendTweet])
{
    TWTweetComposeViewController *tweetSheet = 
    [[TWTweetComposeViewController alloc] init];
    [tweetSheet setInitialText:@"initial text"];
    [tweetSheet addImage:[UIImage imageNamed:image]];

    // Callback
    tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result) {
        // if tweet was successful
        if(result == TWTweetComposeViewControllerResultDone) {

            // Get the accounts
            account = [[ACAccountStore alloc] init];
            ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

            [account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) 
             {
                 // if access granted I populate the array
                 if (granted == YES) {
                     NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];

                     ACAccount *account1 = [arrayOfAccounts objectAtIndex:0];
                     ACAccount *account2 = [arrayOfAccounts objectAtIndex:1];

                     NSString *username1 = account1.username;
                     NSString *username2 = account2.username;

                     // Always same order
                     NSLog(userName1);
                     NSLog(userName2);

                 }
             }];

            [self furtherMethodsInCaseOfSuccessfulTweet];


        } else if(result == TWTweetComposeViewControllerResultCancelled) {
            NSLog(@"twit canceled");
        }
        [self dismissViewControllerAnimated:YES completion:nil];
    };


    [self presentModalViewController:tweetSheet animated:YES];

}
else
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"No tweet is possible on this device" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
    [alertView show];

}   
}我找到了一个方法

与其在tweetcomposeviewcontroller的insctance上查找用户名,不如使用来验证AccountStore收集的名称

(使用json代替xml)

通过分析结果,我们可以得到用户最后一条推文的日期/时间(“状态”标签),瞧,我们使用了最后一个帐户。 此外,您还可以在上测试qwery结果

感谢@thesancook