I know there are bunch of questions here related to this topic but i couldn't find any that matches my issue. I have subclass of UITableViewCell
named "CustomTableViewCell".
The below mentioned code works fine however, i have check marks in my cell and i wanted to stop the reusability since the max number of cells will not exceed 25, hence it would no affect the performance, i guess after many searches, i found out that i have to either remove the tableView dequeueReusableCellWithIdentifier
method or just change the identifier to nil, but unfortunately, i get empty cell when i i do that, and my app crashes what am i missing here?
This works fine BUT it reuses cell.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
...
...
...
...
return cell;
}
While instead, this code crashes:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:nil];
if (cell == nil) {
cell = [[CustomTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
...
...
return cell;
}