ios - cellForRowAtIndexPath doesn't work -


on xcode project have view tableview. have "special" string contains objects populate array populates tableview. example:

nsstring *myvalues=[[nsstring alloc]init];  myvalues = @"aaa$bbb$ccc?111$222$333?"; 

as can see characters $ , ? separate objects. when call view populate array string tableview doesn't work. here code:

file.h:

#import <uikit/uikit.h>  @interface equipaggiovc : uiviewcontroller <uitableviewdelegate, uitableviewdatasource>{     uitableview *tableviewequipaggio;     uitableviewcell *nibloadedcell;      nsmutablearray *arrayequipaggio;      nsstring *stringadati; } @property (nonatomic, retain) iboutlet uitableview *tableviewequipaggio; @property (nonatomic, retain) iboutlet uitableviewcell *nibloadedcell; @property (nonatomic, retain) nsmutablearray *arrayequipaggio; @property (nonatomic, retain) nsstring *stringadati;  @end 

file.m:

#import "equipaggiovc.h" #import "appdelegate.h" #import "classequipaggio.h" @interface equipaggiovc ()  @end  @implementation equipaggiovc @synthesize tableviewequipaggio; @synthesize nibloadedcell; @synthesize arrayequipaggio; @synthesize stringadati; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {         // custom initialization     }     return self; }  -(nsstring *)uuid {     //to create id     cfuuidref uuidref = cfuuidcreate(null);     cfstringref uuidstringref = cfuuidcreatestring(null, uuidref);     cfrelease(uuidref);     return [(nsstring *)uuidstringref autorelease]; } -(void)loadtestdata:(nsstring*)stringadatiarray{  //populate array string.     if(stringadatiarray!=nil){         nsarray *elenco=[stringadatiarray componentsseparatedbystring:@"?"];          (int i=0; i<([elenco count]-1) ; i++) {              nsstring *dettagliequipaggio=[[nsstring alloc]init];              dettagliequipaggio=[elenco objectatindex:i];             nsarray *dettagli=[dettagliequipaggio componentsseparatedbystring:@"$"];             classequipaggio *aequipaggio=[[classequipaggio alloc]init];             aequipaggio.idmembro=[dettagli objectatindex:0];             aequipaggio.sessomembro=[dettagli objectatindex:1];             aequipaggio.datanascitamembro=[dettagli objectatindex:2];              [arrayequipaggio addobject:aequipaggio];             [aequipaggio release];          }     }  }   - (uitableviewcell *)tableview:(uitableview *)tableequipaggioview cellforrowatindexpath:(nsindexpath *)indexpath {      static nsstring *cellidentifier = @"cell";     static nsstring *sloadnibnamed;     uitableviewcell *cell;       classequipaggio *aequipaggio=[arrayequipaggio objectatindex:indexpath.row];     cell = [tableequipaggioview dequeuereusablecellwithidentifier:cellidentifier];     sloadnibnamed=@"equipaggiocell";       if (cell == nil) {          [[nsbundle mainbundle] loadnibnamed:sloadnibnamed owner:self options:null];         cell = [self typenibloadcell:aequipaggio.idmembro];     }      // configure cell     uilabel *tiposessolabel = (uilabel*) [cell viewwithtag:1];     tiposessolabel.text = aequipaggio.sessomembro;      uilabel *datanascitalabel=(uilabel*)[cell viewwithtag:2];     datanascitalabel.text=aequipaggio.datanascitamembro;      return cell; }     -(nsinteger)tableview:(uitableview*)tableview numberofrowsinsection:(nsinteger)section{     return [arrayequipaggio count]; } -(uitableviewcell *)typenibloadcell:(nsstring *)named{     return nibloadedcell; } - (bool)tableview:(uitableview *)tableview caneditrowatindexpath:(nsindexpath *)indexpath {     // return no if not want specified item editable.     return no; } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return 1; }   - (void)viewdidload {     [super viewdidload];     arrayequipaggio=[[nsmutablearray alloc]init];     stringadati=[[nsstring alloc]init];     tableviewequipaggio=[[uitableview alloc]init];  }   -(void)viewdidappear:(bool)animated{     appdelegate *appdelegate=(appdelegate*)[[uiapplication sharedapplication]delegate];      uibarbuttonitem * btnindietroa = [[[uibarbuttonitem alloc] initwithtitle:@"indietro"                                                                        style:uibarbuttonitemstylebordered                                                                       target:self                                                                       action:@selector(editnavbuttonpressed)]autorelease];      [self.navigationitem setleftbarbuttonitem:btnindietroa];     stringadati = [[nsuserdefaults standarduserdefaults] objectforkey:@"stringadati"];      if(stringadati!=nil){          [arrayequipaggio removeallobjects];         [self loadtestdata:stringadati];     }  }   - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. } -(void)dealloc{     [super dealloc]; } @end 

on nib file tableview has connection delegate , datasource, iboutlet connected it.

thanks support.

edit: [arrayequipaggio count] return 0.

by looks of question problem method cellforrowatindexpath not being called , said [arrayequipaggio count] return 0.

since using array @ method numberofrowsinsection return value of 0 normal table not calling method cellforrowatindexpath. since telling table there no rows.

if want table populated check array return value greater 0.

in nutshell has no data populate table, why doesnt work.

check in viewdidappear:(bool)animated pulling stringadati.

nslog(@"info: %@",stringadati); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -