Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 'indexPathWithIndexes:length:' differ in signedness

What is the warning due to ?? How to make it work?

Thanks

like image 528
Biranchi Avatar asked Jan 21 '26 01:01

Biranchi


2 Answers

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).

like image 54
Kendall Helmstetter Gelner Avatar answered Jan 23 '26 21:01

Kendall Helmstetter Gelner


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.

like image 30
Mike Avatar answered Jan 23 '26 20:01

Mike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!