objective-c – 如何从int创建NSIndexPath?

前端之家收集整理的这篇文章主要介绍了objective-c – 如何从int创建NSIndexPath?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
错误信息:

cast of ‘int’ to “NSIndexPath *’ is disallowed with ARC

码:

NSInteger CurrentIndex;

[self tableView:(UITableView *)horizontalTableView1 didSelectRowAtIndexPath:(NSIndexPath *)int_CurrentIndex];

如何解决这个错误

解决方法

您不能直接将int变量转换为NSIndexPath.但是你可以从一个int变量中创建一个NSIndexPath.

您需要一个部分索引和行索引来创建一个NSIndexPath.如果你的UITableView只有一个部分,那么:

Objective-C的

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:0];

迅速

let indexPath: NSIndexPath = NSIndexPath(forRow: rowIndex,inSection: 0)
原文链接:https://www.f2er.com/c/112092.html

猜你在找的C&C++相关文章