Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode unable to dequeue a cell with identifier

my work is about `UITableView. Each time I run my project, this error appears :

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell1 - must register a nib or a class for the identifier or connect a prototype cell in a storyboard 

I checked a hundred times my cell identifier in my storyboard and in my code are the same. Code (defaut code from UITableViewController) :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath     {     static NSString *CellIdentifier = @"Cell1";     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];      // Configure the cell...      return cell; } 

Picture of Table View Cell properties : enter image description here

I created and implemented a subclass of UITableViewCell for my cell.

Any idea why this is not working ?

Any way (line of code) to know what is the identifier of a cell ?

Thanks

Edit : Screenshot of my interface builder.

IB

Edit 2 : Text of customCell.h

#import <UIKit/UIKit.h>  @interface customCell : UITableViewCell  @end 

New error appears when I run the project :

[<choixActiviteViewController 0x7591ac0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Cell1. 

choixActiviteViewController is a subclass of UITableViewController and is the custom class of Choix Activite View Controller.

like image 935
GoldXApp Avatar asked Sep 29 '13 23:09

GoldXApp


2 Answers

Instead of:

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

Try:

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if this does not work then, also add:

  if (cell == nil) {     cell = [[customCell alloc] init]; } 
like image 198
Abdullah Shafique Avatar answered Oct 02 '22 07:10

Abdullah Shafique


Ok, your problem is that you're using Static cells, instead of Prototype cells. Just change your UITableView Content type.

Prototype cells option

like image 31
ssantos Avatar answered Oct 02 '22 09:10

ssantos