我得到了要执行的代码行 -
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]);
}];
}
}
}];
当我将acccount类型对象传递给 accountsWithAccountType:方法时,我得到一个空数组。当我开始调试此代码时,我得到了帐户类型对象的描述。
打印accountType的说明:
identifier:com.apple.twitter
描述:Twitter
的objectID: 的x coredata:// C4E0FB79-AAAF-4E87-92AD-C80137717067 / ACCOUNTTYPE / P25
支持身份验证是
supportsMultipleAccounts YES
supportedDataclasses(null)
syncableDataclasses(null)
我错过了什么? 请帮我解决这个问题。 提前谢谢。