user1179912
user1179912

Reputation: 871

Any issues if we use individual cell identifier for each Cell in UITableView-iPhone

In the below code i have used individual cell identifier for each cell,Which works well.

-(UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   NSString *identifier =[NSString stringWithFormat:@"ID_%d",indexPath.row];
   UITableViewCell *cell = [self.tv dequeueReusableCellWithIdentifier:identifier];

   if(cell==nil)
   {
      UITableViewCell *cell = [self.tv dequeueReusableCellWithIdentifier:identifier];
      cell.textLabel.text=@"data";
   }
   return cell;

}

Any Performance,Memory or any other problem, in the below code?

Upvotes: 0

Views: 257

Answers (2)

Simon Lee
Simon Lee

Reputation: 22334

Performance issues without a doubt. The whole point of the cell identifier is that a table view can re-use existing cells quickly rather than creating (and storing) new ones for each row.

The cell idents should be specific to the type of cell. If you have a table view with three 'types' of cell then use three idents.

Upvotes: 2

Ilanchezhian
Ilanchezhian

Reputation: 17478

If you use individual identifier, then the cells will not be reused. Each UITableViewCell will be different.

And in your code, if cell == nil, then again you are calling deque... If there is no cell with identifier, then you have to allocate a new UITableViewCell.

Upvotes: 3

Related Questions