例如,我正在使用Facebook API获取我的个人资料:
[FBRequestConnection startWithGraphPath:@"/me"
parameters:nil
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"RESULT: %@", result);
}];
我该如何回应:
2014-10-21 16:45:40.435 FacebookTestApp[***] RESULT: {
"first_name" = Richard;
gender = male;
id = *********************;
"last_name" = Topchiy;
link = "https://www.facebook.com/app_scoped_user_id/******/";
locale = "en_US";
name = "Richard Topchiy";
timezone = 3;
"updated_time" = "2014-05-20T17:34:52+0000";
verified = 1;
}
我可以访问这样的数据:
FBGraphObject *obj = (FBGraphObject *)result;
NSString *str = obj[@"first_name"];
但有没有办法使用这样的API:
FBGraphObject *obj = (FBGraphObject *)result;
NSString *name = obj.first_name;
我在官方文档中没有找到这个,我无法创建" FBGraphUser"。我做错了什么,或Facebook已禁用此功能?
答案 0 :(得分:0)
FBGraphUser
是一种协议。所以你可以做到以下几点:
FBGraphObject<FBGraphUser> *user = (FBGraphObject<FBGraphUser>*)result;