Skip to content

Instantly share code, notes, and snippets.

@Dimillian
Created January 21, 2013 16:52
Show Gist options
  • Save Dimillian/4587394 to your computer and use it in GitHub Desktop.
Save Dimillian/4587394 to your computer and use it in GitHub Desktop.
-(void)onTwitterButton:(id)sender
{
if ([TWTweetComposeViewController canSendTweet]) {
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[HUD show:YES];
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error){
dispatch_async(dispatch_get_main_queue(), ^{
if (granted){
MSTwitterSelectorViewController *TWSelector =
[[MSTwitterSelectorViewController alloc]initWithAccounts:[account accountsWithAccountType:accountType]];
[TWSelector setDelegate:self];
UINavigationController *twitterNC = [[UINavigationController alloc]initWithRootViewController:TWSelector];
[self presentModalViewController:twitterNC animated:YES];
}
else{
[self displayTwitterAccessErrorMessage];
[HUD hide:YES];
}
});}];
}
else{
[self displayPleaseRegisterTwitterMessage];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment