我正在枚举ChecklistItem
表中的实体,以查看哪些实体的priority
(NSNumber 属性)为 1。checklistItems
与Checklist
.
在这个简单的代码中,第一个 NSLog 工作正常,并报告我的几个 ChecklistItems 的优先级为 1。但第二个 NSLog 永远不会被调用。为什么是这样?我认为我错误地构建了“if”语句,但我不知道如何。
for (ChecklistItem *eachItem in checklist.checklistItems){
NSLog(@"Going through loop. Item %@ has priority %@.", eachItem.name, eachItem.priority);
if (eachItem.priority == [NSNumber numberWithInt:1]) {
NSLog(@"Item %@ has priority 1", eachItem.name);
}
}