3

ここにはおそらく私の 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
    }
}

ありがとう、アンディ

4

1 に答える 1

2

lldb の問題は、 Objective C の整数比較エラーとまったく同じようです。

カール・ノーラムは彼の応答で言った:

確認済み - lldb IR インタープリターのバグです。

これを修正するパッチへのリンクは次のとおりです


あなたのコードに関して、私はこのテストで成功せずにバグを再現しようとしました:

NSString *lineGroupString = @"-1";
NSInteger lineGroup = [lineGroupString integerValue];
if(lineGroup >= 0)
{
    NSLog(@"positive");
}
else
{
    NSLog(@"negative"); // This log is correctly called every time
}

多分あなたはNSLogこれのためにデバッグしようとするべきです (特にlineGroupString、関数に入った直後の値は何ですか?)。

于 2013-07-22T10:21:18.453 に答える