Error message:
cast of 'int' to "NSIndexPath *' is disallowed with ARC
Code:
NSInteger CurrentIndex;
[self tableView:(UITableView *)horizontalTableView1 didSelectRowAtIndexPath:(NSIndexPath *)int_CurrentIndex];
How do I fix this error?
You can't cast an int
variable to an NSIndexPath
directly. But you can make an NSIndexPath
from an int
variable.
You need a section
index and row
index to make an NSIndexPath
. If your UITableView
has only one section
then:
Objective-C
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:0];
Swift
let indexPath: NSIndexPath = NSIndexPath(forRow: rowIndex, inSection: 0)
Swift 4
let indexPath = IndexPath(row: rowIndex, section: 0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With