【发布时间】:2014-08-14 16:42:38
【问题描述】:
在进行减法后比较两个 NSInteger 时遇到一个奇怪的问题,任何想法为什么这个比较返回“”而不是 false?我检查以确保调试器中的所有变量都有值
NSInteger totalPhotosLeft = self.totalPhotosInRoll - self.currentPhotosFetchedCount;
if (self.enumerateCount < totalPhotosLeft) {
...//never goes here, comparison above always returns < nil >
}
我的属性
@property (nonatomic) NSInteger currentPhotosFetchedCount;
@property (nonatomic) NSInteger enumerateCount;
@property (nonatomic) NSInteger totalPhotosInRoll;
viewDidLoad
self.currentPhotosFetchedCount = 60;
self.enumerateCount = 15;
self.totalPhotosInRoll = 65;
【问题讨论】:
-
返回“
”是什么意思? -
当我签入调试器时: po self.enumerateCount "
-
使用
p self.enumerateCount < totalPhotsLeft。po用于print object。这不是一个对象。 -
啊,谢谢!我把它写成答案
标签: ios objective-c ios7 comparison nsinteger