我的 C 知识在这里可能存在一个漏洞,但我对为什么会发生这种情况有点困惑。
(lldb) p lineGroup
(NSInteger) $17 = -1
(lldb) p (lineGroup > 4)
(bool) $18 = true
(lldb) p (lineGroup < 0 )
(bool) $19 = false
(lldb) p (-1 < 0)
(bool) $20 = true
(lldb) p ((int)lineGroup < 0 )
(bool) $21 = false
(lldb) p ((int)lineGroup > 4)
(bool) $22 = true
(lldb)
lineGroup
变量分配如下:
- (void)gotLineGroupInformation:(NSString *)lineGroupString
{
NSInteger lineGroup = [lineGroupString integerValue];
if(lineGroup >= 0)
{
// Always gets called
}
else
{
// Never gets called
}
}
谢谢,安迪