错误信息:
ARC 不允许将“int”转换为“NSIndexPath *”
代码:
NSInteger CurrentIndex;
[self tableView:(UITableView *)horizontalTableView1 didSelectRowAtIndexPath:(NSIndexPath *)int_CurrentIndex];
如何修复此错误?
错误信息:
ARC 不允许将“int”转换为“NSIndexPath *”
代码:
NSInteger CurrentIndex;
[self tableView:(UITableView *)horizontalTableView1 didSelectRowAtIndexPath:(NSIndexPath *)int_CurrentIndex];
如何修复此错误?
您不能将int变量NSIndexPath直接转换为。但是你可以NSIndexPath从一个int变量中创建一个。
您需要一个section索引和row索引来制作NSIndexPath. 如果你UITableView只有一个section,那么:
Objective-C
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:0];
迅速
let indexPath: NSIndexPath = NSIndexPath(forRow: rowIndex, inSection: 0)
斯威夫特 4
let indexPath = IndexPath(row: rowIndex, section: 0)
Swift 3.0
let indexPath : IndexPath = IndexPath(item: currentIndex, section: 0)