I sent "Signed Comparision" warnings (aka -Wsign-compare) for my iOS project in Xcode (unexpectedly, it was disabled by default). After that, a lot of warnings appeared:
/Users/michalciuba/projects/GlobeMobile/Classes/ACMailController.m:86:19: Comparison of integers of different signs: 'NSInteger' (aka 'long') and 'NSUInteger' (aka 'unsigned long')
They are usually called by comparing a property row NSIndexPaththat is equal NSIntegerto the value returned by the count method for NSArray, for example:
if(indexPath.row < [self.myDataArray count])
You can simply fix the warning by custom:
if(indexPath.row < (NSInteger)[self.myDataArray count])
However, this must be done if in every place where such values โโare compared. And they are compared in dozens of places. I wonder if there is a better and smarter way to solve this problem? I do not want to turn off this warning, because it can help prevent problems like unsigned integer underflow.
source
share