Created
August 12, 2016 17:24
-
-
Save odrobnik/ef04514ed0c3f255d061f96fb4df36ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension CollectionType where Generator.Element == NSIndexPath | |
{ | |
func indexPathsWithSectionModified(by modifier: Int) -> [NSIndexPath] | |
{ | |
var modifiedIndexPaths = [NSIndexPath]() | |
for indexPath in self | |
{ | |
let modifiedIndexPath = NSIndexPath(forItem: indexPath.item, inSection: indexPath.section + modifier) | |
modifiedIndexPaths.append(modifiedIndexPath) | |
} | |
return modifiedIndexPaths | |
} | |
func indexPathsWithItemModified(by modifier: Int) -> [NSIndexPath] | |
{ | |
var modifiedIndexPaths = [NSIndexPath]() | |
for indexPath in self | |
{ | |
let modifiedIndexPath = NSIndexPath(forItem: indexPath.item + modifier, inSection: indexPath.section) | |
modifiedIndexPaths.append(modifiedIndexPath) | |
} | |
return modifiedIndexPaths | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment