iphone - Populating UITableView on a secondary view -
i have code has initial table , when click index, loads view. have code populating array correctly, code have wont populate table using array. have exact same code used populate main table, won't populate. heres code:
- (uitableviewcell *) tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithframe:cgrectzero]; } cell.selectionstyle = uitableviewcellselectionstyleblue; nslog(@"questions array = %@", self.answersarray); cell.textlabel.text = [_answersarray objectatindex:indexpath.row]; return cell; }
for reason wont print out array. have array property , being initialized in viewdidload method:
nsinteger row = _indexofquestion.row; _tempstr = [nsstring stringwithformat:@"http://**.***.**.**/getanswer.php?num=%d", row]; self.answersarray = [[nsmutablearray alloc] init]; self.answersarray = [nsmutablearray arraywithobject: _selectedquestion]; for(int = 1; <= 4; i++) { _hoststr = [_tempstr stringbyappendingformat:@"&ans=answer%d", i]; nsdata *dataurl = [nsdata datawithcontentsofurl:[nsurl urlwithstring: _hoststr]]; nsstring *serveroutput = [[nsstring alloc] initwithdata:dataurl encoding:nsasciistringencoding]; [self.answersarray addobject: serveroutput]; }
some of things might have gone wrong -
- is
nsarray
populated data? (you said data present). - if data present, see if have linked
uitabelview
in interface builder variable in code. - did link
uitableview
delegate , datasource correct file? - did inherit
uitableviewdelegate
,uitableviewdatasource
in.h
file ?
Comments
Post a Comment