我的json响应是这样的。
{
"continent_code" = EU;
"country_code" = al;
"country_id" = 2;
"country_name" = Albania;
},
{
"continent_code" = AF;
"country_code" = dz;
"country_id" = 3;
"country_name" = Algeria;
},
我的代码是这样的。
country_selected=2;
NSMutableArray *wholeJsonArray = [LoginResult objectForKey:@"Response"];
for(NSDictionary *countname in wholeJsonArray)
{
/*
NSString *cName = [NSString stringWithFormat:@"%@",[countname
objectForKey:@"country_name"]];
[countryArray addObject:cName];
*/
NSString *countryName = [countname objectForKey:@"country_name"];
if(countryName)
[countryArray addObject:countryName];
NSString *stateName=[countname objectForKey:@"state_name"];
if(stateName)
[stateArray addObject:stateName];
}
for(NSDictionary *cid in wholeJsonArray)
{
NSNumber *number = [cid objectForKey:@"country_id"];
if(number)
[idcountry addObject:number];
NSNumber *statenumber=[cid objectForKey:@"state_id"];
if(statenumber)
[idstate addObject:statenumber];
}
}
我的问题是,如果用户选择国家 id 2,然后在数组字段中比较这个值,然后在标题标签中显示是阿尔巴尼亚。
那么我该怎么做这个输出呢?
请帮我。
提前致谢。