我正在尝试实施 Facebook 发布程序。您能帮我了解如何检查该帐户是否存在于 iPhone(iOS6 功能)中。我看到了他们使用此类代码的 WWDC 会议:
if (self.accountStore == nil) {
self.accountStore = [[ACAccountStore alloc] init];
}
ACAccountType * facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
//Now we can obtain some extra permissions
NSArray * permissions = @[@"publish_stream"];
//NSArray * permissions = @[@"user_about_me"];
NSDictionary * dict = @{ACFacebookAppIdKey : FB_APP_ID, ACFacebookPermissionsKey : permissions, ACFacebookAudienceKey : ACFacebookAudienceEveryone};
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) {
__block NSString * statusText = nil;
if (granted) {
statusText = @"Logged in";
NSArray * accounts = [self.accountStore accountsWithAccountType:facebookAccountType];
self.facebookAccount = [accounts lastObject];
NSLog(@"account is: %@", self.facebookAccount);
self.statusLabel.text = statusText;
[self postToFeed];
}
else {
self.statusLabel.text = @"Login failed";
NSLog(@"error is: %@", error);
}
}];
但是,如果帐户不存在,我会收到一个错误:
Error Domain=com.apple.accounts Code=6 "The operation couldn’t be completed
可能是我错过了一些东西..但我不完全明白我应该做什么。如果您发布一些关于如何使用这个新的 iOS 6 功能的教程或链接也会很好,因为 facebook 教程不是很清楚。