Understanding iOS Compiler Warnings – Prototype Cells Must Have Reuse Identifiers

Prototype Cells Must Have Reuse Identifiers

You will get this warning if you add a table view controller
to a storyboard. By default, a table view uses prototype cells, and since no reuse identifier has been specified immediately
after you add the table view controller, you get this warning.

To fix this problem, select the table cell (not the table view), go to the
Properties Inspector and set the Identifier
to Cell, or some other descriptive
text.

In the table view controller’s tableView:cellForRowAtIndexPath: method, you can use the identifier
to reference the cell and use it as a prototype to  create new cells. For example:

– (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString *CellIdentifier
= @”CustomerCell”;

    UITableViewCell *cell =

      [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];

    // Configure the
cell…

      CustomerEntity *customer
= [self.customer objectAtIndexPath:indexPath];

      cell.textLabel.text =
[customer.firstName

                        stringByAppendingFormat:@” %@”,
customer.lastName];

    return cell;

}

For explanations of other compiler errors and warnings, check out our new book site: http://www.iOSAppsForEveryone.com

Kevin McNeish
Eight-time .NET MVP Recipient
Apple iOS Author, Trainer
http://www.iOSAppsForEveryone.com 

FourBooks

One thought on “Understanding iOS Compiler Warnings – Prototype Cells Must Have Reuse Identifiers”

  1. Hello Kevin,

    I am new in iPhone development. plz suggest me the best books for iPhone development which contains creating web services and all…

Leave a Reply

Your email address will not be published. Required fields are marked *


*