拨打电话:

-(void)viewDidLoad)
{
    .....
     [appDelegate.session openWithCompletionHandler:^(FBSession *session,
                                                     FBSessionState status,
                                                     NSError *error) {
        self.loginView = [[FBLoginView alloc] initWithReadPermissions:@[@"basic_info", @"email", @"user_birthday", @"user_location"]];
        self.loginView.delegate = self;
    }];
}

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                        user:(id<FBGraphUser>)user {


    NSLog(@"User firstName From Facebook %@", user.firstName);
    NSLog(@"User lastNameFrom Facebook %@", user.lastName);
    NSLog(@"User birthday From Facebook %@", user.birthday);
    NSLog(@"User country From Facebook %@", user.country);
    NSLog(@"User Email From Facebook %@", user.email);

    NSLog(@"User location From Facebook %@", user.location);
    NSLog(@"User location.location From Facebook %@", user.location.location);
    NSLog(@"User location.location.country From Facebook %@", user.location.location.country);


}

日志:

//我收到firstName,lastName,birthday,country和email就好了

对于user.Location:

2014-04-19 16:37:16.143 App[56522:60b] User location From Facebook {
    id = 093483980708726711;
    name = "San Francisco, California";
}

2014-04-19 16:37:16.143 App[56522:60b] User location.location From Facebook (null)
2014-04-19 16:37:16.143 App[56522:60b] User location.location.country From Facebook (null)

我也试过,但没有用:

[user objectForKey:@"country"]

我究竟做错了什么? 我怎样才能回到这个国家?

===============>>#1 票数:2 已采纳

尝试这个:

NSLog(@"Location name >>> %@", [user objectForKey:@"location"][@"name"]);

NSArray *tempArray = [[user objectForKey:@"location"][@"name"] componentsSeparatedByString:@","];

NSLog(@"City >>> %@", [tempArray objectAtIndex:0]);

NSLog(@"Country >>> %@", [tempArray objectAtIndex:1]);

  ask by user1107173 translate from so

未解决问题?本站智能推荐: