I found this in a category in a (very) old project of mine. You could easily
speed it up by using arrays, but this version worked well enough for my needs.
- (NSIndexPath*) indexPathByAddingIndexPath:(NSIndexPath*) indexPath {
NSIndexPath* path = [self copy];
for (NSUInteger i = 0; i < indexPath.length ; i++) {
path = [path indexPathByAddingIndex:[indexPath indexAtPosition:i]];
}
return path;
}
- (NSIndexPath *)indexPathByAddingIndexInFront:(NSUInteger)index {
NSIndexPath* indexPath = [NSIndexPath indexPathWithIndex:index];
return [indexPath indexPathByAddingIndexPath:self];
}
Thanks,
Jon
> On Jun 1, 2015, at 11:06 AM, Dave <[email protected]> wrote:
>
> Hi All,
>
> I’ve got an Index Path, that needs to have an extra level added to it at the
> beginning.
>
> e.g.
>
> 0.1.2.3.4
>
> Needs to be:
>
> 0.0.1.2.3.4
>
> Is there are easy way to do this that doesn’t involve playing with NSUInteger
> Arrays?
>
> If not I think I’ll write a category method that does it, any tips greatly
> appreciated.
>
> All the Best
> Dave
>
>
> _______________________________________________
>
> Cocoa-dev mailing list ([email protected])
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/jhull%40gbis.com
>
> This email sent to [email protected]
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]