this is my piece of code:
这是我的一段代码:
NSUInteger indexArr[] = {1,2,3,4};
NSIndexSet *indexSet = [NSIndexPath indexPathWithIndexes:indexArr length:4];
Is there a way to declare the indexArr inline, like
有没有办法声明indexArr内联,比如
NSIndexSet *indexSet = [NSIndexPath indexPathWithIndexes:{1,2,3,4} length:4];
or something? It's because I'm writing a test with some reference Paths and I want to save lines of code that are not usefull for anybody...
或者其他的东西?这是因为我正在编写带有一些参考路径的测试,我想保存对任何人都没用的代码行......
Best regards, hijolen
最好的问候,hijolen
1 个解决方案
#1
11
The only problem with your attempt is that you need to cast it so that the compiler knows it is the right type.
尝试的唯一问题是你需要强制转换它,以便编译器知道它是正确的类型。
NSIndexSet *indexSet = [NSIndexPath indexPathWithIndexes:(NSUInteger[]){1,2,3,4} length:4];
#1
11
The only problem with your attempt is that you need to cast it so that the compiler knows it is the right type.
尝试的唯一问题是你需要强制转换它,以便编译器知道它是正确的类型。
NSIndexSet *indexSet = [NSIndexPath indexPathWithIndexes:(NSUInteger[]){1,2,3,4} length:4];