Ios 将NSInteger转换为nsindepath
基本上,我将数组的索引存储在NSInteger中。我现在需要它作为nsindepath,我正在努力查看并找到一种方法将我的NSInteger转换为nsindepath,以便可以重用它 使用以下课堂方法 如下所示使用,并且在使用后不要忘记释放myIndexPath对象Ios 将NSInteger转换为nsindepath,ios,objective-c,nsindexpath,nsinteger,Ios,Objective C,Nsindexpath,Nsinteger,基本上,我将数组的索引存储在NSInteger中。我现在需要它作为nsindepath,我正在努力查看并找到一种方法将我的NSInteger转换为nsindepath,以便可以重用它 使用以下课堂方法 如下所示使用,并且在使用后不要忘记释放myIndexPath对象 NSIndexPath *myIndexPath = [[NSIndexPath alloc] initWithIndex:[myIntObj intValue]]; 对于int索引: NSIndexPath *path = [N
NSIndexPath *myIndexPath = [[NSIndexPath alloc] initWithIndex:[myIntObj intValue]];
对于int
索引
:
NSIndexPath *path = [NSIndexPath indexPathWithIndex:index];
根据创建节点0中要指向的项的索引
要在UITableView
中使用indexPath,更合适的方法是
NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section];
如果您需要一个
nsindepath
用于UITableView
,您可以使用indexPathForRow:instation:
()。传递到表视图的索引路径必须正好包含两个指定节和行的索引。使用indexPathWithIndex:
创建的索引路径只包含一个索引,不能与表视图一起使用。Swift 3:
let indexPath = IndexPath(row: 0, section: 0)
您需要
nsindepath
做什么?对于UITableView
,是否需要它?在调用sqlite的update语句时使用它。我想我现在转换成了nsindepath,但我需要nsindepath.row,这会抛出一个错误。有什么想法吗?您不能在使用indexPathWithIndex:
创建的索引路径上调用行
。要创建索引路径,您可以在其上调用row
,您可以使用indexPathForRow:instation:
。谢谢。我还能做path.row吗?还是我的羽绒被划过了?
let indexPath = IndexPath(row: 0, section: 0)