0

在我的 iphone 应用程序中,我正在使用XML-RPC wordpress API访问由 wordpress 支持的博客,并且我正在通过 XML-RPC 方法wp.getUsers连接获取用户列表,一切正常,我得到如下响应(NSLog输出)

2012-07-24 11:13:19.317 projectABC[1465:207] (
        {
        "display_name" = "Ravi Interior Design";
        email = "info@xyz.com";
        nicename = abiqsd;
        registered = "2012-05-11 11:58:52 +0000";
        "user_id" = 15;
        username = abssid;
    },
        {
        "display_name" = "qqHeuer";
        email = "aheuer@xyz.com";
        nicename = adamhequer;
        registered = "2012-05-18 15:59:30 +0000";
        "user_id" = 44;
        username = adamhequer;
    },
        {
        "display_name" = "Asdasm Rseyses";
        email = "xyz@abc.net";
        nicename = adaqmraeyes;
        registered = "2012-06-02 18:51:06 +0000";
        "user_id" = 160;
        username = adaqmreyeqs;
    },

现在我只需要将display_name存储在 NSArray 中,但我不知道如何从上述 XML-RPC 响应中仅提取 display_name,任何人都可以帮助我,请提前谢谢

4

2 回答 2

1

假设您打印的是 NSArray of Dictionaries,

NSLog(@"%@",[yourArray valueForKeyPath:@"display_name"])
于 2012-07-24T06:04:53.587 回答
0

对于字典数组。

int i;
NSMutableArray *display_name = [[NSMutableArray alloc] init];
for(i=0;i<[Arr count];++i)
{
    [display_name addobject:[[Arr objectAtIndex:i] valueForKey:@"display_name"]];
    NSLog(@"%@", [[Arr objectAtIndex:i] valueForKey:@"display_name"]);
}
于 2012-07-24T06:15:12.907 回答