DIJO JOSEPH DIJO JOSEPH - 22 days ago 11
Objective-C Question

How to create a UITableview cell without using dequeueReusableCellWithIdentifier

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

Cell *cell = (ChannelViewTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];


NSString *channelName;
channelName= [NSString stringWithFormat:@"Enter Channel %ld Name", (long)indexPath.row+1];
indexPathRow= indexPath.row+1;
return cell;

}

Answer

You can create one by using

[UITableViewCell alloc] initWithStyle:<#(UITableViewCellStyle)#> reuseIdentifier:<#(nullable NSString *)#>]

but as already said by @MuraliMohan and @Larme we dequee to improve performance by avoiding creation of unecessary cells.

The way it is done is simple, lets assume that you have 100 cells to display. As the device screen is too small for all that you will at most be displaying 15 cell at a time to the user, without dequeing you will be generating 100 cells and displaying 15. What dequeing does is when a cell goes off screen the OS will reuse it for the next cell to display so instead of 100 you will have only 16 cells on memory.

Basically, just keep dequeing but if you want try generating a lot of cells in a test app without dequeing to see how performance decreases ;)

Comments