比较 NSInteger 和 int 时出现的疯狂问题
在将 NSInteger 与 int 进行比较时,我遇到了一个疯狂的问题,如下所示:
NSInteger count = [dictionary count];
if (count == 0) {
// Do something
}
else {
// Do something
}
当计数为零时,运行 if 子句中的片段代码,但是当计数数字更改时,不运行 if 子句中的片段代码(这是正确的),但 else 子句中的片段代码也不会运行。当我调试时,光标总是跳过 else 子句。
我尝试将计数更改为 int 或将其与 NSNumber 进行比较,但没有任何变化。
有谁知道如何解决这个问题?
I have a crazy problem when comparing an NSInteger to int, as follows:
NSInteger count = [dictionary count];
if (count == 0) {
// Do something
}
else {
// Do something
}
When the count is zero, the snipped code in the if clause is run, but when the count number is changed, the snipped code in the if clause is not run (this is correct), but the snipped code in the else clause is not run either. When I debug, the cursor always jumps over the else clause.
I tried to change count number to int or compare it as an NSNumber, but nothing changed.
Does anyone know how to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里没有任何与 NSInteger 和 int 相关的内容。 if else 的逻辑是,无论发生什么情况,都必须调用其中一个。因此,如果没有调用它们,则说明发生了其他错误。你可以只 NSLog 两个 if 和 else 子句吗?如果你能告诉我 if 和 else 子句里面有什么,那就更好了
There is nothing related to NSInteger and int here. The logic of if else is that exactly one of them has to be called, no matter what happens. So, if none of them is called, something else happened wrongly. Can you just NSLog both of the if and else clause. It is also better if you show me what is inside if and else clause