Hi Forum,
can someone please explain to me that if i have this code
so let me see if i even know what the heck i am talking about. so the "dequeueReusableCellWithIdentifier" method is purely for performance.
basically we are saying if the cell exists and its off screen just re-use it when I need to draw another one. So if we dont have any off screen.. lets say my table only has 5 rows which all 5 fit on the screen. At that point there is nothing to "dequeue" so i need to create new cells. Hence the IF statement Makes sense. But i ran the exact same code with the if statement commented out, AND IT STILL RUNS!..... i am so confused Please shed some light on this.
can someone please explain to me that if i have this code
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Top Places Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
so let me see if i even know what the heck i am talking about. so the "dequeueReusableCellWithIdentifier" method is purely for performance.
basically we are saying if the cell exists and its off screen just re-use it when I need to draw another one. So if we dont have any off screen.. lets say my table only has 5 rows which all 5 fit on the screen. At that point there is nothing to "dequeue" so i need to create new cells. Hence the IF statement Makes sense. But i ran the exact same code with the if statement commented out, AND IT STILL RUNS!..... i am so confused Please shed some light on this.