当前位置: 动力学知识库 > 问答 > 编程问答 >

objective c - How to fetch this response in one array

问题描述:

this response i am getting from web service. how to fetch only cities record??

 Data = (

{

Cities = (

{

CityCode = 21;

Name = Cork;

Numbers = (

{

Number = 2349990;

PauseOne = 3;

PauseTwo = 3;

}`enter code here`

);

}

)

网友答案:
NSDictionary *cities = myJson[@"Data"][0][@"Cities"][0];

NSLog(@"City Name is = %@", cities[@"Name"]);
NSLog(@"City Code is = %d", [cities[@"CityCode"] intValue]);
网友答案:

This Code is Finally used for you:

NSMutableArray *arrFinalAllCities = [[NSMutableArray alloc]init];
    NSMutableArray *arrData = [responseObject objectForKey:@"Data"];
    for (int a=0; a<arrData.count; a++)
    {
        NSMutableArray *arrCity = [[arrData objectAtIndex:a] objectForKey:@"Cities"];
        for (int b=0; b<arrCity.count; b++)
        {
            [arrFinalAllCities addObject:[arrCity objectAtIndex:b]];
        }
    }
    NSLog(@"%@",arrFinalAllCities);
网友答案:

the response u hav posted looks like an nsdictionary. not a server returned json. can u post the exact json returned by server? tip: convert nsdata to nsstring and post dat

分享给朋友:
您可能感兴趣的文章:
随机阅读: