Got Empty array from accountsWithAccountType: in IPhone

235 Views Asked by At

I got belo lines of code to execute -

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)
            {
                ACAccount *twitterAccount = [arrayOfAccounts lastObject];

                NSDictionary *message = @{@"status": @"My First Twitter post from iOS6"};

                NSURL *requestURL = [NSURL
                                     URLWithString:@"http://api.twitter.com/1/statuses/update.json"];

                SLRequest *postRequest = [SLRequest
                                          requestForServiceType:SLServiceTypeTwitter
                                          requestMethod:SLRequestMethodPOST
                                          URL:requestURL parameters:message];

                postRequest.account = twitterAccount;

                [postRequest performRequestWithHandler:^(NSData *responseData,
                                                         NSHTTPURLResponse *urlResponse, NSError *error)
                 {
                     NSLog(@"Twitter HTTP response: %i", [urlResponse 
                                                          statusCode]);
                 }];
            }
        }
    }];

I got an empty array while I'm passing acccount type object to accountsWithAccountType: method. While I have started to debug this code I got below description of account type object.

Printing description of accountType:

identifier: com.apple.twitter

description: Twitter

objectID: x-coredata://C4E0FB79-AAAF-4E87-92AD-C80137717067/AccountType/p25

supportsAuthentication YES

supportsMultipleAccounts YES

supportedDataclasses (null)

syncableDataclasses (null)

is there something missed by me? please help me to sort out this. thanks in advance.

0

There are 0 best solutions below