我得到了要执行的代码行-
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:
ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil
completion:^(BOOL granted, NSError *error)
{
if (granted == YES)
{
NSArray *arrayOfAccounts = [account
accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
ACAccount *twitterAccount = [arrayOfAccounts lastObject];
NSDictionary *message = @{@"status": @"My First Twitter post from iOS6"};
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)
{
NSLog(@"Twitter HTTP response: %i", [urlResponse
statusCode]);
}];
}
}
}];
当我将帐户类型对象传递给accountsWithAccountType:方法时,我得到了一个空数组。当我开始调试此代码时,我得到了以下帐户类型对象的描述。
accountType的打印说明:
标识符:com.apple.twitter
描述:推特
对象ID:x-coredata://C4E0FB79-AAAF-4E87-92AD-C80137717067/AccountType/p25
支持认证 YES
支持MultipleAccounts 是
支持的数据类(空)
同步数据类(空)
我有什么遗漏吗?请帮我解决这个问题。提前致谢。