【发布时间】:2014-01-07 05:57:35
【问题描述】:
在XCode5,我有这个代码
1 - (BOOL)checkValidPNGImage{
2 NSData *imagedata = [NSData dataWithContentsOfFile:self.imageFullPath];
3 if ([imagedata length] < 4)
4 return NO;
5 const char * bytes = (const char *)[imagedata bytes];
6 if (bytes[0] != 0x89 || bytes[1] != 0x50)
7 return NO;
8 if (bytes[[imagedata length] - 2] != 0x60 ||
9 bytes[[imagedata length] - 1] != 0x82)
10 return NO;
11 return YES;
12 }
在第 6 行和第 8 行会收到警告
Comparison of constant 137 with expression of type 'const char' is always true
和
Comparison of constant 130 with expression of type 'const char' is always true
如何解决这个问题?顺便说一句,我从某个我忘记的地方得到了上面的代码,所以我打开了任何其他替代方法来检查有效的 png
【问题讨论】:
标签: ios xcode compiler-warnings