The completion block of requestAccessToAccountsWithType
is called on an arbitrary queue so you can't call a UI element (your postTextField) in it.
You should wrap the code with dispatch_async call:
- (void)postToTwitter
{
ACAccountType *accountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[self.accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (granted == YES) {
if ([self.twitterAccounts count] > 0) {
ACAccount *twitterAccount = [self.twitterAccounts objectAtIndex:[AppController sharedAppController].currentUser.twitterAccount.accountId.integerValue];
NSDictionary *message = @{@"status":self.postTextField.text};
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) {
}];
}
}
});
}];
}