Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将NSInteger转换为nsindepath_Ios_Objective C_Nsindexpath_Nsinteger - Fatal编程技术网

Ios 将NSInteger转换为nsindepath

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

基本上,我将数组的索引存储在NSInteger中。我现在需要它作为nsindepath,我正在努力查看并找到一种方法将我的NSInteger转换为nsindepath,以便可以重用它

使用以下课堂方法

如下所示使用,并且在使用后不要忘记释放myIndexPath对象

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)