将NSInteger转换为NSIndexpath [英] Convert NSInteger to NSIndexpath

查看:1299
本文介绍了将NSInteger转换为NSIndexpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我在NSInteger中存储数组的索引。我现在需要它作为NSIndexpath,我很难看到并找到一种方法将我的NSInteger转换为NSIndexpath,所以我可以重用它。

Basically I am storing an index of an array in a NSInteger. I now need it as an NSIndexpath, I'm struggling to see and find a way to convert my NSInteger to NSIndexpath so I can reuse it.

推荐答案

对于int 索引

NSIndexPath *path = [NSIndexPath indexPathWithIndex:index];

根据参考

要在 UITableView 中使用indexPath,更合适的方法是

To use the indexPath in a UITableView, the more appropriate method is

NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section];

这篇关于将NSInteger转换为NSIndexpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆