简体   繁体   English

无法从Facebook图形API响应iOS访问事件名称

[英]Can't access event name from Facebook graph api response iOS

I am calling the graph api to retrieve my user's events.And I get back an NSDictionary response. 我正在调用图api来检索用户的事件,然后返回NSDictionary响应。 My problem is that I'm trying to access the names of the events but can't figure out the correct way of doing it. 我的问题是,我正在尝试访问事件的名称,但是找不到正确的方法。 Can you please help me with this? 你能帮我吗?

My response : 我的回复 :

 events =     {
    data =         (
                    {
            id = 16245704637388667;
            name = "My event name";
            place =                 {
                id = 278379712223737;
                location =                     {
                    city = Beijing;
                    country = China;
                    latitude = "53.598408783333";
....

Mycode to retrieve the vent name: Mycode检索通风口名称:

 if ([result objectForKey:@"data"]){

                 NSArray *events = [result objectForKey:@"data"];
                 NSString *text=@"You don't have events!";
                 for (NSDictionary* myevent in events) {
                     NSString *myeventName = [myevent objectForKey:@"name"];
                      NSLog(@"%@",myeventName);
                 }

 }

Found a solution: 找到一个解决方案:

    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/events" parameters: @{@"fields": @"name"}]
         startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
             if (!error) {

             NSMutableArray* events = [result objectForKey:@"data"];

             events names = [events valueForKey:@"name"];

         }
     }];`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM