Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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
Iphone 有没有更方便的方法来创建NSIndexPath对象?_Iphone_Objective C_Cocoa Touch_Cocoa - Fatal编程技术网

Iphone 有没有更方便的方法来创建NSIndexPath对象?

Iphone 有没有更方便的方法来创建NSIndexPath对象?,iphone,objective-c,cocoa-touch,cocoa,Iphone,Objective C,Cocoa Touch,Cocoa,上面创建了一个长度=3的nsindepath。有没有办法用更少的语句来做同样的事情?这可能是你能做的最好的了: NSIndexPath *index_path; NSUInteger u_array[] = {0, 0, 0}; index_path = [NSIndexPath indexPathWithIndexes : u_array length : 3]; 这可能是您所能做的最好的: NSIndexPath *in

上面创建了一个长度=3的nsindepath。有没有办法用更少的语句来做同样的事情?

这可能是你能做的最好的了:

    NSIndexPath *index_path;
    NSUInteger   u_array[] = {0, 0, 0};                
    index_path = [NSIndexPath indexPathWithIndexes : u_array length : 3]; 

这可能是您所能做的最好的:

    NSIndexPath *index_path;
    NSUInteger   u_array[] = {0, 0, 0};                
    index_path = [NSIndexPath indexPathWithIndexes : u_array length : 3]; 

只有当您使用iOS时,您才标记了它,因此不确定是哪一个,并且您只对两部分索引路径感兴趣,即表节和行-如果是这种情况,您可以使用[NSIndexPath indexPathForRow:Instation:]。文档的NSIndexPath UIKit添加部分对此进行了描述

只有在您使用iOS时,您才标记了这个,所以不确定是哪个,您只对两部分索引路径感兴趣,即表节和行-如果是这种情况,您可以使用[NSIndexPath indexPathForRow:Instation:]。文档的NSIndexPath UIKit添加部分对此进行了描述

如果您要在UITableView中使用它,那么有一个indexPathForRow:inSection:

+NSIndexPath*indexPathForRow:NSIntegerrow片段:NSIntegersection

以下是如何使用它:

NSUInteger u_array[] = {0, 0, 0}; 
NSIndexPath *index_path = [NSIndexPath indexPathWithIndexes:u_array length:3];

如果您正在谈论在UITableView中使用它,那么有一个indexPathForRow:inSection:

+NSIndexPath*indexPathForRow:NSIntegerrow片段:NSIntegersection

以下是如何使用它:

NSUInteger u_array[] = {0, 0, 0}; 
NSIndexPath *index_path = [NSIndexPath indexPathWithIndexes:u_array length:3];

谢谢你的回答。我的意思是cocoa touch,标签已相应更正。谢谢您的回答。我的意思是cocoa touch,标记已经相应地被更正。因此,对于长度>=3,我们必须满足于至少2条语句。您是否使用它来标识表视图中的一个位置?或者其他原因?实际上,我计划为深入菜单创建一些NSIndexPath常量。因此,对于长度>=3,我们必须满足于至少2条语句。您是否使用它来标识表视图中的一个位置?或者为了别的什么?实际上我正计划为一个深入菜单创建一些nsindepath常量。我问这个问题的原因是我试图在上面的第二条语句中用{0,0,0}代替u_数组。即使使用了类型转换,编译器也不会接受它。我想知道是否有人能做到。你有没有解释为什么不能这样做?是的:你可以用C中的大括号来初始化或分配一个数组,但就其本身而言,大括号中以逗号分隔的项目列表不是数组。或者,换句话说,C中没有数组文字。我问这个问题的原因是我试图在上面的第二条语句中用{0,0,0}代替u_数组。即使使用了类型转换,编译器也不会接受它。我想知道是否有人能做到。你有没有解释为什么不能这样做?是的:你可以用C中的大括号来初始化或分配一个数组,但就其本身而言,大括号中以逗号分隔的项目列表不是数组。或者,换句话说,C中没有数组文字。