objective-c – 如何从int创建NSIndexPath?
发布时间:2020-12-16 03:14:29 所属栏目:百科 来源:网络整理
导读:错误信息: cast of ‘int’ to “NSIndexPath *’ is disallowed with ARC 码: NSInteger CurrentIndex;[self tableView:(UITableView *)horizontalTableView1 didSelectRowAtIndexPath:(NSIndexPath *)int_CurrentIndex]; 如何解决这个错误? 解决方法 您
错误信息:
码: 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) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |