调用时出现“Error Code 8” – iOS

我一直在search谷歌和SO,无法find什么com.apple.accounts错误代码8的手段。 我正在尝试使用iOS 6和Facebook SDK。

我运行这个请求;

if (!_accountStore) _accountStore = [[ACAccountStore alloc] init]; ACAccountType *fbActType = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys: (NSString *)ACFacebookAppIdKey, @"###############", (NSString *)ACFacebookPermissionsKey, [NSArray arrayWithObject:@"email"], nil]; [_accountStore requestAccessToAccountsWithType:fbActType options:options completion:^(BOOL granted, NSError *error) { if (granted) { NSLog(@"Success"); NSArray *accounts = [_accountStore accountsWithAccountType:fbActType]; _facebookAccount = [accounts lastObject]; } else { NSLog(@"ERR: %@",error); // Fail gracefully... } } ]; 

我得到这个错误:

ERR: Error Domain=com.apple.accounts Code=8 "The operation couldn't be completed. (com.apple.accounts error 8.)"

无论我做什么,都不会回报真实。 任何想法将非常感激。

如果我绕过if(granted)并调用这个函数:

 - (void)me{ NSLog(@"Home.m - (void)me"); NSURL *meurl = [NSURL URLWithString:@"https://graph.facebook.com/me"]; SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:meurl parameters:nil]; merequest.account = _facebookAccount; [merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"%@", meDataString); }]; 

然后我看到这个由Facebook返回的这个JSON: {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}}

更新:所以,错误的意思是“客户的访问信息字典有不正确的或缺less的值”。 但我不知道这是什么意思。

您的选项字典中有错误。

 NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys: (NSString *)ACFacebookAppIdKey, @"###############", (NSString *)ACFacebookPermissionsKey, [NSArray arrayWithObject:@"email"], nil]; 

阅读更好的方法声明:“带对象和键的字典”,所以第一个对象,然后键…但你已经插入第一个KEYS,然后OBJECTS(错误的顺序:-)

正确的字典是:

  NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys: @"###############", ACFacebookAppIdKey, [NSArray arrayWithObject:@"email"], ACFacebookPermissionsKey, nil]; 

或者,声明字典文字:

  NSDictionary *options = @{ ACFacebookAppIdKey : @"###############", ACFacebookPermissionsKey : [NSArray arrayWithObject:@"email"] };