Search code examples
iphonensindexpath

NSIndexPath getIndexes method....how?


Am confused with the use of this method and the documentation that lists it as a (void) method.

"on return the index path's indexes"

where does it return anything too?

Should it not be:

- (NSIndexPath *)getIndexes:(NSUInteger *)indexes

getIndexes: Provides a reference to the index path’s indexes.

- (void)getIndexes:(NSUInteger *)indexes

Parameters indexes Pointer to an unsigned integer array. On return, the index path’s indexes. Availability Available in iOS 2.0 and later. Declared In NSIndexPath.h


Solution

  • You have to allocate the NSUInteger array of size [indexPath length] and pass it as argument. The return value will be written there. You have to release that array yourself or do nothing it was created on stack like this:

    NSUInteger array[[indexPath length]];
    [indexPath getIndexes: array];