Skip to content

Commit

Permalink
Merge pull request #184 from cetineremre/patch-2
Browse files Browse the repository at this point in the history
add swift version check for compactmap
  • Loading branch information
rechsteiner authored May 1, 2018
2 parents 30e8d25 + eed4001 commit 83d7464
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Parchment/Classes/PagingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,15 @@ open class PagingViewController<T: PagingItem>:

private func generateItemsForIndexedDataSource() -> [T] {
let numberOfItems = dataSource?.numberOfViewControllers(in: self) ?? 0
return (0..<numberOfItems).enumerated().compactMap{
dataSource?.pagingViewController(self, pagingItemForIndex: $0.offset)
}
#if swift(>=4.1)
return (0..<numberOfItems).enumerated().compactMap{
dataSource?.pagingViewController(self, pagingItemForIndex: $0.offset)
}
#else
return (0..<numberOfItems).enumerated().flatMap{
dataSource?.pagingViewController(self, pagingItemForIndex: $0.offset)
}
#endif
}

private func configureDataSource() {
Expand Down

0 comments on commit 83d7464

Please sign in to comment.