• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Concatenating two NSIndexPath objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Concatenating two NSIndexPath objects (From: Dave <email@hidden>)

  • Prev by Date: Re: NSPathControl
  • Next by Date: Re: Looking at self = [super init].
  • Previous by thread: Concatenating two NSIndexPath objects
  • Next by thread: How to debug a binding exception?
  • Index(es):
    • Date
    • Thread