I've got some code that relies on comparing two NSIndexPaths and executing different code based on their equality or lack thereof (using -isEqual). Most of the time it works properly, but sometimes it doesn't. I've used the debugger console to test the two indexpaths during code execution, and they look identical to me.
Here's the code:
- (BOOL)selectedStreetIsSameAsLastSelectedStreet
{
return [self.indexPathOfSelectedStreet isEqual:self.previousObject.indexPathOfSelectedStreet];
}
Here's the output during the execution of the code:
(gdb) po self.indexPathOfSelectedStreet
<NSIndexPath 0x60a0770> 2 indexes [26, 1]
(gdb) po self.previousObject.indexPathOfSelectedStreet
<NSIndexPath 0x55b4f70> 2 indexes [26, 1]
(gdb) p (BOOL)[self.indexPathOfSelectedStreet isEqual:self.previousObject.indexPathOfSelectedStreet]
$2 = 0 '\000'
Am I doing something wrong, or is there another way I can reliably test the equality of two NSIndexPaths?