While using tableViews, I have seen this code lots of times.
static NSString* CellIdentifier = @"Cell";
UITableViewCell* cell = [tableView dequeue...:CellIdentifier];
if( cell == nil ) /* note the expression used in the conditional */
{
// do stuff
}
I have also seen the same idea expressed as follows.
static NSString* CellIdentifier = @"Cell";
UITableViewCell* cell = [tableView dequeue...:CellIdentifier];
if( !cell ) /* note the expression used in the conditional */
{
// do stuff
}
In my understanding, these are the same. In the first example, the ==
operator will return if the cell is nil
. The second conditional will also only be true if the cell is nil
. Why is there a discrepancy in the method used to test the cell? Will these conditionals ever return different things?