ios - 隐式转换失去整数精度:警告,64位平台的代码

标签 ios objective-c int nsinteger

在(偶然)更改模拟器(从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/

相关文章:

ios - Swift 中只允许某些类符合协议(protocol)

ios - self.delegate 总是 nil

objective-c - 如何有效地展平 NSOutlineView?

objective-c - UIButton 中的图像比原始图像更暗

java - 如何从文件交替变量中读取值?

java - 如何在java中声明一个数值变量,该变量始终保存固定长度为3位的数字值。

c# - 什么是 Xamarin.Forms 等效于 layoutSubviews?

ios - 如何在我的iOS Xing App中深度链接到个人资料?

iphone - iphone 的时钟计时器应用程序中的 UIPickerView

c - 在 C 中将文件中的字符串和整数扫描到数组中