Can someone explain the difference between
static NSString* CellIdentifier = @"Cell";
and
NSString *CellIdentifier = [NSString stringWithFormat: @"Cell%i", indexPath.row];
When should I use the first one and where the second?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This identifier (assuming there are no others) will identify a pool of cells from which all rows will pull when they need a new cell.
This identifier will create a pool of cells for each row, i.e. it will create a pool of size 1 for each row, and that one cell will always be used for only that row.
Typically you will want to always use the first example. Variations on the second example like:
would be useful if you want every other row to have a certain background color or something of that sort.
An example of how to properly setup cell creation from here: