开发者

Crazy problem when comparing NSInteger to int

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 nothi开发者_如何学Cng changed.

Does anyone know how to solve this problem?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜