Nick
Nick

Reputation: 8493

Shift NSIndexPath entities

I read NSIndexPaths all the time for uitableviews etc. But I'm having difficultly manipulating an existing indexpath.

I want to take an existing indexpath increment/shift each section while preserving the rows. So that indexPath.section 0 becomes indexPath.section 1 etc. moving the associated row count non-desctructively.

I know NSIndexPath is immutable but are their any categories or nice patterns that support this?

Upvotes: 0

Views: 177

Answers (1)

DrummerB
DrummerB

Reputation: 40211

Well, you could always just create a new slightly changed instance from the old one.

NSIndexPath *newPath = [NSIndexPath indexPathForRow:oldPath.row 
                                          inSection:oldPath.section+1];

Upvotes: 3

Related Questions