Jul*_*les 0 xcode cocoa-touch objective-c analyzer
我收到了以下警告Comparison of unsigned expression < 0 is always false.
我不确定如何修复它?
if(topWindowIndex < 0)
Run Code Online (Sandbox Code Playgroud)
它的定义是......
NSUInteger topWindowIndex = [allWindows count] - 1;
Run Code Online (Sandbox Code Playgroud)
如果[allWindows count] - 1永远不会是负面的,那么测试(以及它控制的代码)是不必要的.如果它可以是否定的,您应该声明topWindowIndex为签名类型(int或NSInteger).
一个更好的解决方案,IMO,是直接存储计数并使用它:
NSUInteger numWindows = [allWindows count];
...
if (numWindows < 1) ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3631 次 |
| 最近记录: |