Re: Concatenating two NSIndexPath objects
Re: Concatenating two NSIndexPath objects
- Subject: Re: Concatenating two NSIndexPath objects
- From: Jonathan Hull <email@hidden>
- Date: Mon, 01 Jun 2015 14:43:56 -0700
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@hidden> 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@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden