开发者

How to declare good old C-Array in Objective-C inline?

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

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


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜