How to convert NSIndexPath to NSInteger?
Asked Answered
D

1

8

I have searched and found a previous answer for this question here. The problem is that the answer marked as a solution does not work. Inside my tableView:didSelectRowAtIndexPath: method, I have

NSInteger *currentRow = indexPath.row;

and it gives me the warning 'Incompatible integer to pointer conversion initializing 'NSInteger *'(aka 'int *') with an expression of type 'NSInteger' (aka 'int').

Any help is appreciated!

Drear answered 18/12, 2011 at 6:30 Comment(0)
T
22

NSInteger is not a class, so it doesn't need an asterisk:

NSInteger currentRow = indexPath.row;
Topple answered 18/12, 2011 at 6:34 Comment(1)
also very useful is to track the index.row by assigning it to a yourView.tag or yourLabel.tag so you can access information from custom cells and the like...so it would be yourTextView.tag = indexPath.rowGranite

© 2022 - 2024 — McMap. All rights reserved.