NSIndexPath warnings in Obj-C
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 'index开发者_运维知识库PathWithIndexes:length:' differ in signedness
What is the warning due to ?? How to make it work?
Thanks
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).
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.
精彩评论