누구나 Xcode/Objective C에서 이러한 결과를 설명 할 수 있습니까? 확실히 -2 이제까지 내가 바로 업을 같은 오답을 본 적이보다 큰 31목표 C 정수 비교 오류
(lldb) p dayOfMonth
(int) $37 = -2
(lldb) p (dayOfMonth > 31)
(bool) $38 = true
(lldb) p (dayOfMonth > (int)31)
(bool) $39 = true
(lldb) p (dayOfMonth > (float)31)
(bool) $40 = false
을 테스트해야하며 잘못 해석 될 수있는 방법 상상할 수없는 일은 없다. 디버거와 마찬가지로 dayOfMonth도 int입니다.
편집 추가 : 여기에 (일부 관련이없는 라인 컷으로) 실패 코드입니다 :
NSRange monthdays = [self.calendar rangeOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:self.displayedDate];
int dayOfMonth = i+1-shift; // negative days are at end of prev month; days higher than length of month are in next
if (dayOfMonth < 1) cellView.dayLabel = prevMonthDays.length + dayOfMonth;
if (dayOfMonth > monthdays.length) cellView.dayLabel = dayOfMonth - monthdays.length;
두 번째 if
사실 평가 DAYOFMONTH가 부의 경우.
몇 가지 이상한 진 것. – Undo
어떤 이유로 인해 사물이 부호없는 유형으로 변환되고 있습니다. 나는 왜 문서를 빨리 스캔하는지 보지 못한다. 나는 그것이 버그라고 생각하고있다. 나는 여기에서도 같은 결과를 얻었지만 GDB에서는 정상적으로 작동합니다. 대신 사용할 수 있습니까? –
그것은 디버거에만있는 것이 아닙니다. 컴파일 된 코드에서 같은 오류가 발생합니다. –