开发者

How to parse an array with specific key in iphone

开发者 https://www.devze.com 2023-03-19 00:22 出处:网络
I have an array (result) which is showing output on console like this. I am getting result as facebook multiquery output. Here is the definition of result.

I have an array (result) which is showing output on console like this. I am getting result as facebook multiquery output. Here is the definition of result.

-(void)request:(FBRequest*)request didLoad:(id)result {

NSLog(@" result is %@",result);

}

My multiquery foramt is here.

NSString* fql1 = [NSString stringWithFormat:@"select uid,username,name from user where uid == %lld", _session.uid];

NSString* fql2 = [NSString stringWithFormat:@"SELECT likes,message FROM stream WHERE source_id = %lld limit 50", _session.uid];

NSString* queries = [NSString stringWithFormat:@"{\"UserRecord\":\"%@\",\"WallData\":\"%@\"}",fql1,fql2];

NSDictionary* params = [NSDictionary dictionaryWithObject:queries forKey:@"queries"];

[[FBRequest requestWithDelegate:self] call:@"facebook.fql.multiquery" params:params];

result is (

{

"fql_result_set" =  (

                {

        name = "My Login Name";

        uid开发者_JAVA百科 = 1000024646062353;

        username = myuserid;

    }

);

name = UserRecord;

},

{

"fql_result_set" =   (

                {

        likes =  {

            "can_like" = 1;

            count = 2;

            friends =  (

                         {
                    uid = 100002483363608;

                }

            );

  href = "http://www.facebook.com/browse/?type=likes&id=108202343353";

 sample =  (

            );
            "user_likes" = 1;

        };

        message = "This wall post is not from application.";
  },


);

name = WallData;

}

)

I want to fetch make another which will keep only "message" values and one another which will keep "count" value respected with message. How will I separate these values from above array output


Edited version:

NSString *messageString = [[[[result objectAtIndex:1]objectForKey:@"fql_result_set" ] objectAtIndex:0] objectForKey:@"message"];
NSnumber *countNumber = [[[[[result objectAtIndex:1]objectForKey:@"fql_result_set" ] objectAtIndex:0] objectForKey:@"likes"] objectForKey:@"count"];
0

精彩评论

暂无评论...
验证码 换一张
取 消