基本上,我将数组的索引存储在 NSInteger 中。我现在需要它作为 NSIndexpath,我正在努力寻找并找到一种将我的 NSInteger 转换为 NSIndexpath 的方法,以便我可以重用它。
最佳答案
对于一个 int index
:
NSIndexPath *path = [NSIndexPath indexPathWithIndex:index];
根据 the reference 创建节点 0 中项目的索引以指向.
要在 UITableView
中使用 indexPath,更合适的方法是
NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section];
关于ios - 将 NSInteger 转换为 NSIndexpath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6454723/