-1

这是代码:

    while((fingerYLast - fingerAt.y) > fingerMoveThresh)
    {
        if( (activeCard) < (allCardList.count - 2))
        {
            [self sayOut:@"TRUE"];
            activeCard = activeCard + 1;
        }
        else
        {
            //WTF????
            [self sayOut:[NSString stringWithFormat:@"FALSE %i %i",
                          activeCard, (allCardList.count - 2)]];
        }
        fingerYLast -= fingerMoveThresh;            
    }

我检查了测试值,activeCard 为 -1,allCardList 有 10 个成员。

activeCard = -1;
(activeCard) < (allCardList.count - 2) //evaluates as false

(activeCard+1) < (allCardList.count - 1) //evaluates as true

有任何想法吗?

4

1 回答 1

3

我没有用那种语言编码,但我敢打赌 allCardList.count 返回一个无符号数,而 -2 试图将其推到零以下,将返回一个非常大的无符号数。

于 2013-05-20T10:57:30.007 回答