Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter integration issue with ACAccountStore (iOS 5)

When I run below code with iOS 6.0, Its working

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

[account requestAccessToAccountsWithType:accountType options:nil
                                  completion:^(BOOL granted, NSError *error)
     {
         dispatch_async(dispatch_get_main_queue(), ^{

             if (granted) 
             {
                 //MY CODE
             }
         });

     }];

and When I run this code with iOS 5.0 or 5.1, It crashes with following output,

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[ACAccountStore requestAccessToAccountsWithType:options:completion:]: 
unrecognized selector sent to instance 0x68a57c0'

Don't know about this weird crash log..

Please tell me, How to get rid of this..

like image 946
Mehul Mistri Avatar asked Feb 18 '23 07:02

Mehul Mistri


1 Answers

Use below method:

[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
 {

   if (granted) {

            //Your code
            }
        }
   }];
like image 131
yen Avatar answered Mar 04 '23 18:03

yen