ios - TableView reload data troubles -
i have function creates few arrays , fills them data. execute function viewdidload
.
in function add [self.tableview reloaddata];
i set breakpoints etc , doesn't go numberofrowsintableview
etc. should [self.tableview reloaddata]
execute table view functions appears on iphone screen?
** update **
firstly function called :
- (void)viewdidload { [super viewdidload]; viewcontroller *getdeals = [[viewcontroller alloc] init]; [getdeals topdealsrecieve:[[nsuserdefaults standarduserdefaults] objectforkey:@"devicetoken"]]; [self.tableview setdelegate:self]; [self.tableview setdatasource:self]; [self.tableview reloaddata];
the function topdealsrecieve gets arrays :
nslog(@"%@", responseobject); alllogos = [[responseobject valueforkey:@"data"] valueforkey:@"logo"]; allcontent = [[responseobject valueforkey:@"data"] valueforkey:@"content"]; allpostode = [[responseobject valueforkey:@"data"] valueforkey:@"postcode"]; nslog(@"%lu", (unsigned long)allcontent.count); allname = [[responseobject valueforkey:@"data"] valueforkey:@"name"]; alladdress = [[responseobject valueforkey:@"data"] valueforkey:@"address"]; alladdress2 = [[responseobject valueforkey:@"data"] valueforkey:@"address2"]; alllat = [[responseobject valueforkey:@"data"] valueforkey:@"lat"]; alllong = [[responseobject valueforkey:@"data"] valueforkey:@"lng"]; // refresh table view [self.tableview setdelegate:self]; [self.tableview setdatasource:self]; [self.tableview reloaddata];
and in :
-(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { nslog(@"wnks %lu",(unsigned long)allcontent.count); return allcontent.count; }
all variables available throughout code , assigned :
// global var nsarray *alllocationsid; nsarray *alllocationscity; nsarray *alllogos; nsarray *allcontent; nsarray *allpostode; nsarray *allname; nsarray *alladdress; nsarray *alladdress2; nsarray *alllat; nsarray *alllong;
at top of viewcontroller. did work when getarray function wasn't function , placed in viewdidload.
you should add these 2 lines method viewdidload
before execute [self.tableview reloaddata];
this
[self.tableview setdelegate:self]; [self.tableview setdatasource:self]; [self.tableview reloaddata];
Comments
Post a Comment