objective c - JSON Data Not Parsed in iOS -
i newbie in ios development. want parse json data webservices have written folliwing code
- (void)viewdidload { nsurl * url=[nsurl urlwithstring:[nsstring stringwithformat:@"http://www.janvajevu.com/webservice/latest_post.php?page=%d",pagenum]]; dispatch_async(kbgqueue, ^{ data = [nsdata datawithcontentsofurl: url]; [self performselectoronmainthread:@selector(fetcheddata:) withobject:data waituntildone:yes]; }); } -(void)fetcheddata:(nsdata *)responsedata { if (responsedata.length > 0) { nserror* error; self.json= [nsjsonserialization jsonobjectwithdata:responsedata options:kniloptions error:&error]; if ([[_json objectforkey:@"data"] iskindofclass:[nsarray class]]) { nsarray *arr = (nsarray *)[_json objectforkey:@"data"]; [self.navuarray addobjectsfromarray:arr]; [self.navutable reloaddata]; nslog(@"json data %@",self.navuarray); } self.navutable.hidden=false; }
here self.json
json dictionary , self.navuarray
nsmutablearray
when print array returns num. please give me solution it.
its navuarray
not initialized before adding objects array. initialize before call data , add objects it.
Comments
Post a Comment