Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Beginner in Xcode; reuse identifiers?

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!

like image 769
user3804662 Avatar asked Jul 04 '14 08:07

user3804662


4 Answers

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"];
like image 158
Suhail kalathil Avatar answered Oct 09 '22 00:10

Suhail kalathil


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"];
like image 22
michaelsnowden Avatar answered Oct 08 '22 23:10

michaelsnowden


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

like image 21
Oxcug Avatar answered Oct 08 '22 23:10

Oxcug


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.

like image 24
Moinuddin Girach Avatar answered Oct 09 '22 00:10

Moinuddin Girach