
if ([self.indexPathSelected compare:indexPath] == NSOrderedSame){ NSLog(@" %d %d %d %d",self.indexPathSelected.row,self.indexPathSelected.section,indexPath.row,indexPath.section);} 打印:
0 0 0 0
0 0 1 0
0 0 2 0
0 0 3 0
0 0 4 0
0 0 5 0
我期待它只打印0 0 0 0.
我在这里做错了什么?
解决方法 由于您将indexPathSelected设置为nil,因此您需要在进行比较之前确保它不为零.if (self.indexPathSelected && [self.indexPathSelected compare:indexPath] == NSOrderedSame){ NSLog(@" %d %d %d %d",indexPath.section);} 根据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.
以上是内存溢出为你收集整理的ios – 比较NSIndexPath全部内容,希望文章能够帮你解决ios – 比较NSIndexPath所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)