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..
Use below method:
Try update for this:
This is a bit late, but the reason you're getting that error is that requestAccessToAccountsWithType:options:completion: is new in iOS 6.
In iOS 5 and earlier use the requestAccessToAccountsWithType:withCompletionHandler method instead (this method is deprecated in iOS 6)
See the docs: https://developer.apple.com/library/ios/documentation/Accounts/Reference/ACAccountStoreClassRef/Reference/Reference.html#//apple_ref/doc/uid/TP40011021-CH1-SW12
Thanks @CReaTuS, I want to clarify this up to some more bit, Note that in case of iOS6 we make SLRequest where in iOS5 we have to perform request using TWRequest. See below-
Happy coding :)