Obj-C 中的 NSIndexPath 警告
我在创建 NSIndexPath 时收到警告,
NSInteger arr[] = {0,3};
[NSIndexPath indexPathWithIndexes:arr length:2]
警告:传递 'indexPathWithIndexes:length:' 的参数 1 时的指针目标符号不同
警告是什么原因?如何让它发挥作用?
谢谢
I am getting a warning while creating the NSIndexPath,
NSInteger arr[] = {0,3};
[NSIndexPath indexPathWithIndexes:arr length:2]
warning: pointer targets in passing argument 1 of 'indexPathWithIndexes:length:' differ in signedness
What is the warning due to ?? How to make it work?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使数组的类型为
NSUInteger
(无符号)。它告诉您,因为 NSIndexPath 不需要负值,您可能会通过 NSInteger 数组(实际上是 int)传入负值。
You need to have the array be of type
NSUInteger
(unsigned).It's telling you that because NSIndexPath does NOT want negative values, which you could potentially be passing in via an NSInteger array (really an int).
假设您正在针对 iPhone 进行开发,您应该使用 UIKit 附加功能来创建索引路径来表示
UITableViews
中的位置。您应该像这样构建示例:NSIndexPath *myIndexPath = [NSIndexPath indexPathForRow:0 inSection:3];
请参阅 此 Apple 文档 了解更多信息。Assuming you're developing for the iPhone, you should use the UIKit additions intended for creating index paths to represent positions in
UITableViews
. You should construct your example like so:NSIndexPath *myIndexPath = [NSIndexPath indexPathForRow:0 inSection:3];
See this Apple documentation for more information.