iphone - Do not get proper value in tableview from few rows first -


nsmutablearray *wholejsonarray = [loginresult objectforkey:@"response"]; //nsmutablearray *values=[nsmutablearray arraywitharray:[loginresult allvalues]];     nsmutablearray *statenamearray=[loginresult objectforkey:@"response"]; for(nsdictionary *countname in wholejsonarray) {      nsstring *cname = [nsstring stringwithformat:@"%@",[countname objectforkey:@"country_name"]];     [countryarray addobject:cname];  } for(nsdictionary *cid in wholejsonarray) {      nsnumber *number = [cid objectforkey:@"country_id"];     [idcountry addobject:number]; }  for(nsdictionary *statename in statenamearray) {      nsstring *sname=[nsstring stringwithformat:@"%@",[statename objectforkey:@"state_name"]];     [statearray addobject:sname]; } 

i wrote above code.

country name displayed in table view. state name response gets displayed few rows display have null value , other rows proper value. should remove null value few rows.

thanks in advance.

try this

nsmutablearray *countries = [loginresult objectforkey:@"response"];  for(nsdictionary *country in countries){      nsstring *countryname = country[@"country_name"];    if(countryname)         [countryarray addobject:countryname];      nsnumber *countryid = country[@"country_id"];     if(countryid)         [idcountry addobject:countryid];      nsstring *statename = country[@"state_name"];     if(statename)         [statearray addobject:statename]; } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -