iOS開発初心者です。Facebook SDK を使用して Facebook から友達を取得するときにエラーが発生しました。私のコードは次のとおりです。
Facebookクラス
- (void)fetchFacebookFriend{
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"user_birthday",@"friends_hometown",
@"friends_birthday",@"friends_location",@"friends_work_history",
nil];
if (!FBSession.activeSession.isOpen) {
// if the session is closed, then we open it here, and establish a handler for state changes
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
if (error != nil) {
NSLog(@"Failed to retrive facebook friend.");
return;
}
else{
self.myArray = [[NSMutableArray alloc] init];
NSLog(@"permissions::%@",FBSession.activeSession.permissions);
FBRequest *friendRequest = [FBRequest requestForGraphPath:@"me/friends?fields=name,picture,birthday,hometown,location,work"];
[friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
appDelegate.myFacebookArray = [[NSMutableArray alloc] init];
for (NSDictionary *fbData in [result objectForKey:@"data"]) {
NSLog(@"%@",fbData);
[self.myArray addObject:fbData];
}
}];
}
}];
return;
}
}
ViewController
- (IBAction)pickFriendPressed:(id)sender {
NSLog(@"##Begin");
[[FacebookClass sharedInstance] fetchFacebookFriend];
NSLog(@"##End");
}
出力
##Begin
##End
Json data
##End.Thanksを表示した後、Jsonデータを取得するのを手伝ってください