Reputation: 1759
In my iPhone app I am accessing a WordPress powered blog using XML-RPC WordPress APIs, and I am fetching the userlists through a XML-RPC method wp.getUsers
connection. This is all working fine and I got the response as below (NSLog
output):
2012-07-24 11:13:19.317 projectABC[1465:207] (
{
"display_name" = "Ravi Interior Design";
email = "[email protected]";
nicename = abiqsd;
registered = "2012-05-11 11:58:52 +0000";
"user_id" = 15;
username = abssid;
},
{
"display_name" = "qqHeuer";
email = "[email protected]";
nicename = adamhequer;
registered = "2012-05-18 15:59:30 +0000";
"user_id" = 44;
username = adamhequer;
},
{
"display_name" = "Asdasm Rseyses";
email = "[email protected]";
nicename = adaqmraeyes;
registered = "2012-06-02 18:51:06 +0000";
"user_id" = 160;
username = adaqmreyeqs;
},
Now I need to store only display_name in an NSArray, but I am not getting how to extract only display_name from the above XML-RPC response. How can I achieve this?
Upvotes: 0
Views: 172
Reputation: 22930
For array of Dictionaries.
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"]);
}
Upvotes: 0
Reputation: 10251
Assuming what you printing is NSArray of Dictionaries,
NSLog(@"%@",[yourArray valueForKeyPath:@"display_name"])
Upvotes: 1