iOS Twitter Framework: How to fetch (on the callback) last twitter account used to tweet?
===

Once a user has tweeted something, I need to differentiate which twitter account he used. Lets consider that the user would have 1 or several accounts configured on the phone.

I need tho know this after the tweet is successful, so the proper place would be the callback. I tried to fetch the accounts using ACAccountStore but it provides an array with all the accounts set up on the phone, not a clue about the last account used (not even the order of the array).

Does anyone knows if TWTweetComposeViewController remembers this account and, how to fetch it?

Thanks

My code:



    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];
 
    }   
}


