iphone - NSMutableArray Display Null Value in Table View -


- (void)viewdidload {  self.detailview = [[uitableview alloc] initwithframe:cgrectmake(0, 0, 320, 480)    style:uitableviewstyleplain]; self.detailview.datasource = self; self.detailview.delegate = self; self.detailview.multipletouchenabled=yes; [self.view addsubview:self.detailview]; [super viewdidload]; self.title = nslocalizedstring(@"routes", nil); self.detailarray = [[nsmutablearray alloc] init]; nsstring  *url = [nsstring stringwithformat:@"http://maps.googleapis.com/maps/api/directions/json?origin=chennai&destination=madurai&sensor=false"]; nsurl *googlerequesturl=[nsurl urlwithstring:url]; dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ nsdata* data = [nsdata datawithcontentsofurl: googlerequesturl]; nsstring *somestring = [[nsstring alloc] initwithdata:data encoding:nsasciistringencoding]; nserror* error; nsmutabledictionary* parsedjson = [nsjsonserialization jsonobjectwithdata:data              options:kniloptions  error:&error]; nsarray *allkeys = [parsedjson allkeys];  for(int = 0; < allkeys.count; i++){  if([[allkeys objectatindex:i] isequaltostring:@"routes"]){ nsarray *arr  = [parsedjson objectforkey:@"routes"]; nsdictionary *dic   = [arr objectatindex:0]; nsarray *legs = [dic objectforkey:@"legs"]; for(int = 0;  < legs.count; i++){ nsarray *stepsarr = [[legs objectatindex:i] objectforkey:@"steps"]; (int = 0; < stepsarr.count; i++) { nslog(@"html instruction %@", [[stepsarr objectatindex:i] objectforkey:@"html_instructions"]); nslog(@"############################"); [self.detailarray addobject:[[stepsarr objectatindex:i] objectforkey:@"html_instructions"] ];                 }             }          }      }         });     }  -(nsinteger) numberofsectionsintableview:(uitableview *)tableview{ return 1; }  -(nsinteger) tableview:(uitableview *)table numberofrowsinsection:(nsinteger)section{ return [self.detailarray count];  }   -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {  static nsstring *cellidentifier = @"cell";  uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) {     cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; }   uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(10.0f, 5.0f, 300.0f, 30.0f)]; label.text=[nsstring stringwithformat:@"%@",[self.detailarray objectatindex:indexpath.row]]; label.numberoflines = 3; label.font = [uifont fontwithname:@"helvetica" size:(12.0)]; label.linebreakmode = uilinebreakmodewordwrap; label.textalignment = uitextalignmentleft; [cell.contentview addsubview:label]; [label release];  return cell; } 

i want display detailarray in table view.but display null values in table view.but in nslog display current values.the detailarray having set of direction values. possible display in tableview.if give constant value in displayarray show correctly in tableview. please me if 1 know.i waiting valuable answers,thanks.

updated

after add whole data (values) in after retain , reload tableview bellow...

[self.detailarray retain]; [self.detailview reloaddata]; 

i sure problem solved... :)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -