Skip to content

Commit

Permalink
Fix build issue for Xcode 12.4
Browse files Browse the repository at this point in the history
  • Loading branch information
DenTelezhkin committed May 14, 2021
1 parent f2d6ee9 commit 5b25d6a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

# Next

### Fixed

* Build issue for Xcode 12.4, now compatible with both Xcode 12.5 and 12.4 and lower

## [7.1.1](https://github.com/DenTelezhkin/DTCollectionViewManager/releases/tag/7.1.1)

Note: This is backwards-compatibility release, it only fixes build issue with Xcode 12.5. For future development please consider migrating to DTCollectionViewManager 8.
Expand Down
22 changes: 22 additions & 0 deletions Sources/DTCollectionViewManager/DTCollectionViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ open class DTCollectionViewDataSource: DTCollectionViewDelegateWrapper, UICollec
to: destination)
}

#if swift(<5.4)
/// Implementation of `UICollectionViewDataSource` protocol.
@available(tvOS 10.2, *)
open func indexTitles(for collectionView: UICollectionView) -> [String]? {
if let reaction = unmappedReactions.first(where: { $0.methodSignature == EventMethodSignature.indexTitlesForCollectionView.rawValue }) {
return reaction.performWithArguments((0, 0, 0)) as? [String]
}
return (delegate as? UICollectionViewDataSource)?.indexTitles?(for: collectionView)
}

/// Implementation of `UICollectionViewDataSource` protocol.
@available(tvOS 10.2, *)
open func collectionView(_ collectionView: UICollectionView, indexPathForIndexTitle title: String, at index: Int) -> IndexPath {
if let indexPath = performNonCellReaction(.indexPathForIndexTitleAtIndex, argumentOne: title, argumentTwo: index) as? IndexPath {
return indexPath
}
return (delegate as? UICollectionViewDataSource)?.collectionView?(collectionView,
indexPathForIndexTitle: title,
at: index) ?? IndexPath(item: 0, section: 0)
}
#else
@available(iOS 14.0, tvOS 10.2, *)
/// Implementation of `UICollectionViewDataSource` protocol.
open func indexTitles(for collectionView: UICollectionView) -> [String]? {
Expand All @@ -125,4 +146,5 @@ open class DTCollectionViewDataSource: DTCollectionViewDelegateWrapper, UICollec
indexPathForIndexTitle: title,
at: index) ?? IndexPath(item: 0, section: 0)
}
#endif
}

0 comments on commit 5b25d6a

Please sign in to comment.