如何使用facebook ios API获得雇主姓名

时间:2016-07-27 08:38:00

标签: ios objective-c xcode facebook

这是我的代码:

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{ @"fields" : @"id,first_name,last_name,picture.width(300).height(300),gender,birthday,work"}]startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
            if (!error) {
                fNameUser = [result valueForKey:@"first_name"];
                lNameUser = [result valueForKey:@"last_name"];
                genderUser = [result valueForKey:@"gender"];
                NSLog(@"You Work At: %@", [result valueForKey:@"work"]);

和NSLOG的输出是

You Work At: (
        {
        employer =         {
            id = 12345678909876543;
            name = "Employer Name";
        };
        id = 34234234234343455465;
    }
)

从这个输出我只想得到雇主的名字。我怎么能这样做。

1 个答案:

答案 0 :(得分:0)

你的[result valueForKey:@"work"]在数组开始时同时处于单一索引中,所以我用作0

喜欢

NSString *employername = result[@"work"][0][@"employer"][@"name"];