Understanding iOS Compiler Warnings – Prototype Cells Must Have Reuse Identifiers





0
0
1
175
1002
Oak Leaf Enterprises, Inc
8
2
1175
14.0







Normal
0
false



false
false
false

EN-US
JA
X-NONE














































































































































































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 


 

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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>