在(偶然)更改模拟器(从32位平台到64位平台)时收到很多警告之后,我摆脱了所有int
声明,并将其更改为NSinteger
。
但是我在这段代码中还有另一个警告:
- (IBAction)nextText:(UIBarButtonItem *)sender {
NSInteger i=[self.indexPathArray indexOfObject:[self indexPathForActiveText]];
//before it was int i=...
if (i<[self.indexPathArray count]-1) {
[self moveRows:++i];
}
}
但是在
[self moveRows:++i];
行上,我再次收到此警告:“隐式转换失去整数精度:...”
最佳答案
它应该在64位平台上显示警告。 NSInteger i=[self.indexPathArray indexOfObject:[self indexPathForActiveText]];
因为indexOfObject:
返回NSUInteger.
,所以您的代码应如下所示
NSUInteger i=[self.indexPathArray indexOfObject:[self indexPathForActiveText]];
并且
-(void)moveRows:(NSUInteger)index;
See this apple's doc
关于ios - 隐式转换失去整数精度:警告,64位平台的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22780524/