Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS 5, Storyboards, ARC: UITableview doesn't get populated with data from custom delegate and datasource
    text
    copied!<p>This is my first time I am working on UITableView connected to custom delegate and datasource. Until today, I used to connect to "self". The prequel for this question is <a href="https://stackoverflow.com/questions/12059235/ios-5-storyboards-arc-creating-and-setting-custom-delegate-and-datasource-to-p">here</a>.</p> <p>So, I have two additional UIViews. Using segmented control I put one of the over mentioned UIViews on self.view...</p> <p>Have created two UITableView subclasses and set them as delegate and datasource. Works fine, no leaks or crashes. Checked if the classes getting initialized on segmentedControl index change:</p> <pre><code>- (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization NSLog(@"Nominals got init"); } return self; } </code></pre> <p>NSLog works when changing segment.</p> <p>The question:</p> <p>In my custom delegate class I override the methods required by UITableViewDelegate and UITableViewDataSource protocols.</p> <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 20; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(12, 12, 200, 12)]; lbl.text=@"some nominal"; cell.textLabel.text=@"Nominal"; [cell addSubview:lbl]; return cell; } </code></pre> <p>At moment I am getting exception:</p> <blockquote> <p>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'</p> </blockquote> <p>Well, isn't the cell in my custom delegated class is the same cell of my UITableView I've created:</p> <pre><code>-(void)populateNominals:(int)subCountryID { NominalsTableViewDelegate *del=[[NominalsTableViewDelegate alloc]init]; [self setNominalsDelegate:del]; UITableView *nominalsTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 372) style:UITableViewStylePlain]; [nominalsTableView setDelegate:nominalsDelegate]; [nominalsTableView setDataSource:nominalsDelegate]; [nominalsTableView reloadData]; [self.nominalsView addSubview:nominalsTableView]; } </code></pre> <p>what's my mistake? Thank you in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload