Wednesday, June 19, 2013

NSIndexPath indexPathWithIndexes length example in Objective C (iOS).


NSIndexPath indexPathWithIndexes length

Creates an index path with one or more nodes.

+ (id)indexPathWithIndexes:(NSUInteger *)indexes length:(NSUInteger)length

Parameters
indexes
Array of indexes to make up the index path.
length
Number of nodes to include in the index path.

Return Value of [NSIndexPath indexPathWithIndexes length]
Index path with indexes up to length.

NSIndexPath indexPathWithIndexes length example.
You might use it like this:

NSUInteger indexArr[] = {1,2,3,4};

NSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:indexArr length:4];

Example of [NSIndexPath indexPathWithIndexes length].
This is probably the best you can do:

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

NSIndexPath indexPathWithIndexes length example.
NSIndexPath *someIndexPath = [NSIndexPath indexPathWithIndexes:newIndexes
                                                        length:len];
    NSUInteger newIndexes2[[someIndexPath length]];
    [someIndexPath getIndexes:newIndexes2];

    NSUInteger len2 = sizeof(newIndexes2)/sizeof(NSUInteger);
    NSIndexPath *baseIndexPath2 = [NSIndexPath indexPathWithIndexes:newIndexes2
                                                             length:len2];
    NSUInteger ii;
    NSInteger start = [someIndexPath indexAtPosition:[someIndexPath length] -1];
    for (ii=start; ii<10; ii++) {
        NSIndexPath *newIndexPath2 = [baseIndexPath2 indexPathByAddingIndex:ii];
        NSLog(@"newIndexPath2 = %@", newIndexPath2);
    }

End of NSIndexPath indexPathWithIndexes length example article.