isEqual doesn't always work for NSIndexPath? What can I use in its place?

前端 未结 1 1866
臣服心动
臣服心动 2021-02-02 08:21

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 pr

相关标签:
1条回答
  • 2021-02-02 08:56

    As of iOS 5 you can just use isEqual: (see comments)


    Try [indexPath1 compare: indexPath2] == NSOrderedSame.

    Maybe you found a bug in NSIndexPath. If you try to create a new NSIndexPath with a path that already exists you should get that one instead. So isEqual: probably just compares the pointers and not the actual indices stored.

    0 讨论(0)
提交回复
热议问题