From 5b25d6ab6136b6d11cba84c3445b6754f4edd5fc Mon Sep 17 00:00:00 2001 From: Denys Telezhkin Date: Fri, 14 May 2021 15:25:06 +0300 Subject: [PATCH] Fix build issue for Xcode 12.4 --- CHANGELOG.md | 4 ++++ .../DTCollectionViewDataSource.swift | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd29a2d..9bc5848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Sources/DTCollectionViewManager/DTCollectionViewDataSource.swift b/Sources/DTCollectionViewManager/DTCollectionViewDataSource.swift index e16f3e6..84c3cec 100644 --- a/Sources/DTCollectionViewManager/DTCollectionViewDataSource.swift +++ b/Sources/DTCollectionViewManager/DTCollectionViewDataSource.swift @@ -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]? { @@ -125,4 +146,5 @@ open class DTCollectionViewDataSource: DTCollectionViewDelegateWrapper, UICollec indexPathForIndexTitle: title, at: index) ?? IndexPath(item: 0, section: 0) } + #endif }