iOS Developer

判断两个NSIndexPath是否相等

2016-04-28  本文已影响1084人  Yancy_90

NSIndexPath.h中有这么一个方法:

    // comparison support
- (NSComparisonResult)compare:(NSIndexPath *)otherObject; // sorting an array of indexPaths using this comparison results in an array representing nodes in depth-first traversal order

它的返回值NSComparisonResult是一个枚举

typedef NS_ENUM(NSInteger, NSComparisonResult) {
NSOrderedAscending = -1L, 
NSOrderedSame, 
NSOrderedDescending
};

因此判断两个NSIndexPath是否相可以这样写

BOOL isEqual = ([indexPath1 compare:indexPath2] == NSOrderedSame) ? YES : NO;
上一篇 下一篇

猜你喜欢

热点阅读