我正在使用 Autoscroll 示例中的 Apple TapDetectingImageView 类。
静态分析器显示以下警告:
类/TapDetectingImageView.m:68:30:{68:17-68:29}:警告:
The left operand of '==' is a garbage value
if (tapCounts[0] == 1 && tapCounts[1] == 1) {
~~~~~~~~~~~~ ^
对于下面的附加代码。垃圾值发生在没有先初始化的情况下读取变量。但似乎 tapCounts 已经初始化。
如果应用程序运行良好,我可以忽略它还是应该修改任何内容?
BOOL allTouchesEnded = ([touches count] == [[event touchesForView:self] count]);
// first check for plain single/double tap, which is only possible if we haven't seen multiple touches
if (!multipleTouches) {
UITouch *touch = [touches anyObject];
tapLocation = [touch locationInView:self];
if ([touch tapCount] == 1) {
[self performSelector:@selector(handleSingleTap) withObject:nil afterDelay:DOUBLE_TAP_DELAY];
} else if([touch tapCount] == 2) {
[self handleDoubleTap];
}
}
// check for 2-finger tap if we've seen multiple touches and haven't yet ruled out that possibility
else if (multipleTouches && twoFingerTapIsPossible) {
// case 1: this is the end of both touches at once
if ([touches count] == 2 && allTouchesEnded) {
int i = 0;
int tapCounts[2]; CGPoint tapLocations[2];
for (UITouch *touch in touches) {
tapCounts[i] = [touch tapCount];
tapLocations[i] = [touch locationInView:self];
i++;
}
if (tapCounts[0] == 1 && tapCounts[1] == 1) { // it's a two-finger tap if they're both single taps
tapLocation = midpointBetweenPoints(tapLocations[0], tapLocations[1]);
[self handleTwoFingerTap];
}
}