내 테이블의 ChecklistItem
엔티티를 통해 priority
(NSNumber 특성)이 1 인 것을 확인합니다. checklistItems
은 Checklist
과 다 대 관계입니다.왜이 간단한 'if'문이 작동하지 않습니까 (빠른 열거 형 내부)?
이 간단한 코드에서 첫 번째 NSLog는 정상적으로 작동하고 몇 가지 ChecklistItem에 우선 순위 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);
}
}
이것은 작동하지 않을 것이고, eachItem.priority는 NSNumber – MarkPowell
입니다.하지만 NSNumber has - (int) intValue 메서드를 읽었습니까? 문서에 문제가 있습니까? – Ravin
내 실수는 더 가까이 읽었어야합니다. "intValue"를 놓쳤습니다. – MarkPowell