I am writing code to access my Twitter user account, but I am having problems handling the case when there are no accounts on the device. What I would like to do is to show a warning informing the user that for authentication via Twitter they will first need to create an account in their settings.
Here is my code:
self.accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountTypeTwitter = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[self.accountStore requestAccessToAccountsWithType:accountTypeTwitter options:nil completion:^(BOOL granted, NSError *error) {
if(granted) {
} else if (error){
[SVProgressHUD dismiss];
switch ([error code]){
case (6):
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"No Twitter Account Detected" message:@"Please go into your device settings menu to add your Twitter account." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
break;
}
}
}];
I'm not an expert in the Xcode debugger, but apparently an error occurs in the ACAccountStoreReply thread, about 25 calls in depth after calling [alert show] in a process called ucol_getVersion. The debugger state is EXC_BAD_ACCESS (code = 2, address = 0xcc).
Qaru UIAlertViews, , ( ), AccessToAccountsWithType.
, - Objective-C, 4- .
.