objective c - Couldn't set values in Custom Cell in UITableView from NSMutableArray -


help me rid of dilemma occurred yet when tried dequeued cell (custom cell).below steps , indents did project.

the first drag , drop uitableview in viewcontroller , add viewcontroller.h doing after this

@interface viewcontroller : uiviewcontroller <uitableviewdatasource,uitableviewdelegate> 

then made custom cell 3 uilabels , change height of cell 65.

after made property in viewcontroller.m

@property (nonatomic,strong) nsmutablearray *mytodotitles; 

then in method(viewdidload) did.

mytodotitles = [nsmutablearray arraywithcapacity:10]; [mytodotitles addobject:@"go ride"]; [mytodotitles addobject:@"do university assignments"]; [mytodotitles addobject:@"watch show"]; nsindexpath *indexpath = [nsindexpath indexpathforrow:[self.mytodotitles count]-1 insection:1];   [self tableview:self.mytodotable cellforrowatindexpath:indexpath]; 

after did these things in viewcontroller.m

#pragma mark - table view data source  -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{     nsstring *myidentifier = @"todocell";     todocell *todocell = (todocell*)[tableview dequeuereusablecellwithidentifier:myidentifier];      todocell.todotitlelabel.text = [self.mytodotitles objectatindex:indexpath.row];      return todocell; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{     return [mytodotitles count]; }  - (nsinteger)numberofsectionsintableview:(uitableview *)tableview{     return 1; } 

but when run project dequeued nothing. please help

most have not connected viewcontroller datasource of tableview. done interface builder or code. can check adding self.mytodotable.datasource = self; @ first of viewdidload method.

and also: did mean `

[self tableview:self.mytodotable cellforrowatindexpath:indexpath];`  

in viewdidload ? seems wanted

[self.mytodotable reloaddata]; 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -