11

I have recently started to build a very basic To-Do List in Xcode 5 as my first project. Having practically finished the UI design and build I am now stuck on the implementation of data into my TableView. I have added a list of 13 items in my list and given the first in the list the 'ListPrototypeCell' identifier and all of my code seems correct. My project has 3 identical issues:

Unsupported Configuration; Prototype cells must have reuse identifiers 

I have played around with identifiers on every item, although I have been told I don't need to use an identifier on every item, and I still get these errors.

I am willing to send my project onto anyone that thinks they may be able to help me resolve the issues, to the trained eye it is probably a very basic mistake I have made.

I appreciate any help!

Thanh-Nhon Nguyen
  • 3,402
  • 3
  • 28
  • 41
user3804662
  • 121
  • 1
  • 1
  • 3

5 Answers5

18

Try this Check your storyboard and confirm there is a reuse identifier for your prototypeCell,

enter image description here

And use the same identifier in your

UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"sameReuseIdentifier"];
Suhail kalathil
  • 2,673
  • 1
  • 13
  • 12
  • I upvoted this nice visual representation, but it would be more perfect if the screenshot would hold the same reuse identifier as it holds normally. – holex Jul 04 '14 at 08:35
2

Go into your storyboard, go to the view controller, go to the table view, go to the tableviewcell, go to the identity inspector, and enter something into the field that says "Reuse Identifier"

You use the reuse identifier for initializing cells based off of the style they are in the table view like this:

UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier"];
michaelsnowden
  • 6,031
  • 2
  • 38
  • 83
  • So do I just give the first of my 13 cells (rows in my TableView) the "reuseIdentifier" identifier? If so, what do I do with the other 12 rows in my TableView? Do i give them an identifier too? – user3804662 Jul 04 '14 at 12:16
1

The reason you're getting that error is because some of your prototype cells do not have a reuse identifier on them.

If you don't understand how/when to use prototypes and reuse-id's. You should read: Table View Programming Guide for iOS

Oxcug
  • 6,524
  • 2
  • 31
  • 46
1

reuseidentifier is an id from which you can get cell from it. if you set reuse id "cell" you can access this cell in cellForRowAtIndexPath method

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}

which means that get cell from stroyboard with reuseid "cell". in your case you have to write above two line as follows

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
}

this line shows that every time new cell will be alloc and initialized and it does not use prototype cell.

so prototype cell from storyboard is never used. if you want i can give you demo to mention how it works.

Moinuddin Girach
  • 213
  • 1
  • 10
0

I know this is old but i saw this explanation of reuse identifiers and it really helped me understand why to use reuse identifiers, so I wanted to share in case it helps others.

"The reuseIdentifier is used to group together similar rows in an UITableView; i.e., rows that differ only in their content, but otherwise have similar layouts.

A UITableView will normally allocate just enough UITableViewCell objects to display the content visible in the table. If reuseIdentifier is set to a non-nil value, then when the table view is scrolled, UITableView will first attempt to reuse an already allocated UITableViewCell with the same reuseIdentifier. If reuseIdentifier has not been set, the UITableView will be forced to allocate new UITableViewCell objects for each new item that scrolls into view, potentially leading to laggy animations."

Natalia
  • 1,308
  • 16
  • 23