【发布时间】:2013-07-20 22:12:46
【问题描述】:
我的 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
}
}
谢谢, 安迪
【问题讨论】:
-
你编译的架构是什么?如果是 64 位,则 NSInteger 将是 64 位,而 int 将是 32 位。
-
您的问题只是关于明显错误的调试器输出吗?还是您的代码没有按预期工作?
标签: objective-c c lldb