如何用iphone中的特定键解析数组

时间:2011-07-07 07:35:24

标签: iphone objective-c nsarray nsdictionary fql.multiquery

我有一个数组(结果),它在控制台上显示输出。我得到的结果是facebook多重查询输出。这是结果的定义。

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

NSLog(@“结果为%@”,结果);

}

我的多样式论坛就在这里。

NSString * fql1 = [NSString stringWithFormat:@“选择uid,用户名,来自用户的名称,其中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 = 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;

}

)

我想获取另一个只保留“消息”值的另一个值,并保持“count”值与消息一致。如何将这些值与上面的数组输出

分开

1 个答案:

答案 0 :(得分:1)

编辑版:

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"];