Since you're setting indexPathSelected to nil, you want to make sure it's non-nil before doing a compare.
if (self.indexPathSelected && [self.indexPathSelected compare:indexPath] == NSOrderedSame)
{
NSLog(@" %d %d %d %d", self.indexPathSelected.row, self.indexPathSelected.section, indexPath.row, indexPath.section);
}
According to the documentation on NSIndexPath's compare method:
Parameters
indexPath
Index path to compare.
This value must not be nil. If the value is nil, the behavior is undefined.