在进行减法后比较两个NSIntegers有一个奇怪的问题,为什么这个比较返回“<nil>”而不是false?我检查确保调试器中的所有变量都有值
NSInteger totalPhotosLeft = self.totalPhotosInRoll - self.currentPhotosFetchedCount;
if (self.enumerateCount < totalPhotosLeft) {
...//never goes here, comparison above always returns < nil >
}
我的 property
@property (nonatomic) NSInteger currentPhotosFetchedCount;
@property (nonatomic) NSInteger enumerateCount;
@property (nonatomic) NSInteger totalPhotosInRoll;
viewDidLoad中
self.currentPhotosFetchedCount = 60;
self.enumerateCount = 15;
self.totalPhotosInRoll = 65;
1 回答
调试时我使用的是po而不是p . po用于打印对象,p用于打印输出 .
感谢@rmaddy如此快速地搞清楚这一点