Created
April 27, 2020 09:36
-
-
Save zakbarlow1995/714cf735a96245532c577fb35841c723 to your computer and use it in GitHub Desktop.
Swift - Get IndexPath array between startIndex & endIndex helper function
This file contains 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
func getIndexPathArrayBetween(_ startIndex: Int, and endIndex: Int, section: Int = 0) -> [IndexPath] { | |
assert(startIndex >= 0 && endIndex > startIndex, "startIndex >= 0 && endIndex > startIndex") | |
return (startIndex...endIndex).map { IndexPath(row: $0, section: section) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example use-case: API pagination request result (
apiResult
) returning array of TableViewDataSource (items
)