diff --git a/.gitignore b/.gitignore index 3a9dd72..c7ac36a 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Xcode # build/ +.build/ .DS_Store *.pbxuser !default.pbxuser diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 85e4ccf..5c3583d 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -300,18 +300,18 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1130; ORGANIZATIONNAME = "Mohamed Afifi"; TargetAttributes = { 547447501CA93C1D00F3597E = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1000; + LastSwiftMigration = 1130; }; }; }; buildConfigurationList = 5474474C1CA93C1C00F3597E /* Build configuration list for PBXProject "Example" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -432,6 +432,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -488,6 +489,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -543,7 +545,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = mohamede1945.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -556,7 +558,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = mohamede1945.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme index e5b686b..ba4181b 100644 --- a/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme +++ b/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -1,6 +1,6 @@ - - - - + + - - + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + + + + @@ -40,17 +49,6 @@ - - - - - - + + diff --git a/GenericDataSources.podspec b/GenericDataSources.podspec index 28077c6..95a50db 100644 --- a/GenericDataSources.podspec +++ b/GenericDataSources.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GenericDataSources' - s.version = '3.0.2' + s.version = '3.1.1' s.license = 'MIT' s.summary = 'A generic small composable components for data source implementation for UITableView and UICollectionView.' s.homepage = 'https://github.com/GenericDataSource/GenericDataSource' diff --git a/Package.swift b/Package.swift index 4794a97..58e86a3 100644 --- a/Package.swift +++ b/Package.swift @@ -1,5 +1,21 @@ +// swift-tools-version:5.1 + import PackageDescription let package = Package( - name: "GenericDataSource" + name: "GenericDataSources", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "GenericDataSources", + targets: ["GenericDataSources"]), + ], + dependencies: [ + ], + targets: [ + .target( + name: "GenericDataSources", + dependencies: [], + path: "Sources") + ] ) diff --git a/Sources/AnyBasicDataSourceRepresentable.swift b/Sources/AnyBasicDataSourceRepresentable.swift index d37602b..ec0cd21 100644 --- a/Sources/AnyBasicDataSourceRepresentable.swift +++ b/Sources/AnyBasicDataSourceRepresentable.swift @@ -12,13 +12,13 @@ private class _AnyBasicDataSourceRepresentableBoxBase: BasicDataSourceRepr var items: [Item] { get { fatalError() } - set { fatalError() } + set { fatalError() } // swiftlint:disable:this unused_setter_value } var dataSource: AbstractDataSource { fatalError() } var onItemsUpdated: (([Item]) -> Void)? { get { fatalError() } - set { fatalError() } + set { fatalError() } // swiftlint:disable:this unused_setter_value } } diff --git a/Sources/AnyDataSourceSelectionHandler.swift b/Sources/AnyDataSourceSelectionHandler.swift index e17bb8b..15d90fc 100644 --- a/Sources/AnyDataSourceSelectionHandler.swift +++ b/Sources/AnyDataSourceSelectionHandler.swift @@ -11,7 +11,7 @@ import Foundation /** * Type-erasure for `DataSourceSelectionHandler`. */ -public struct AnyDataSourceSelectionHandler : DataSourceSelectionHandler { +public struct AnyDataSourceSelectionHandler: DataSourceSelectionHandler { private let itemsChanged: (BasicDataSource) -> Void private let configureCell: (BasicDataSource, GeneralCollectionView, CellType, ItemType, IndexPath) -> Void diff --git a/Sources/BasicBlockDataSource.swift b/Sources/BasicBlockDataSource.swift index 0f346e7..aa95cea 100644 --- a/Sources/BasicBlockDataSource.swift +++ b/Sources/BasicBlockDataSource.swift @@ -11,7 +11,7 @@ import Foundation /** A basic data source class that configures the cells with a closure. */ -open class BasicBlockDataSource : BasicDataSource { +open class BasicBlockDataSource: BasicDataSource { /// The configure closure type. public typealias ConfigureBlock = (ItemType, CellType, IndexPath) -> Void diff --git a/Sources/BasicBlockSupplementaryViewCreator.swift b/Sources/BasicBlockSupplementaryViewCreator.swift index a007392..f85d3fe 100644 --- a/Sources/BasicBlockSupplementaryViewCreator.swift +++ b/Sources/BasicBlockSupplementaryViewCreator.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the basic supplementary view creator subclass that does the configuration using a closure. /// For more information see `BasicSupplementaryViewCreator` diff --git a/Sources/BasicDataSource.swift b/Sources/BasicDataSource.swift index a824556..ad588e5 100644 --- a/Sources/BasicDataSource.swift +++ b/Sources/BasicDataSource.swift @@ -18,7 +18,7 @@ import UIKit For sizing cells, you can use `itemSize` for `UICollectionView` and `itemHeight` for `UITableView`. Or if you want to specify a custom size, you can override `ds_collectionView(_:sizeForItemAt:)`, **but needs** to set `useDelegateForItemSize` to `true` otherwise the overriden method will not be called. */ -open class BasicDataSource : AbstractDataSource, BasicDataSourceRepresentable { +open class BasicDataSource: AbstractDataSource, BasicDataSourceRepresentable { /// Returns a string that describes the contents of the receiver. open override var description: String { @@ -57,7 +57,7 @@ open class BasicDataSource : AbstractDataSourc then those properties sets this property to `true`. */ @available(*, unavailable, message: "Now, we can detect if you implemented sizeForItemAt or not") - open var useDelegateForItemSize: Bool = false + open var useDelegateForItemSize: Bool { return false } /// Represents the underlying data source which is `self`. open var dataSource: AbstractDataSource { return self } diff --git a/Sources/BasicDataSourceRepresentable.swift b/Sources/BasicDataSourceRepresentable.swift index 274782f..2095ccd 100644 --- a/Sources/BasicDataSourceRepresentable.swift +++ b/Sources/BasicDataSourceRepresentable.swift @@ -18,7 +18,7 @@ import Foundation /// let dsRepresentable2: AnyBasicDataSourceRepresentable = dataSource2.asBasicDataSourceRepresentable() /// let representables = [dsRepresentable1, dsRepresentable2] /// // representables is an array that doesn't care about the cell only the items. -public protocol BasicDataSourceRepresentable: class { +public protocol BasicDataSourceRepresentable: AnyObject { associatedtype Item /// Represents the underlying data source. @@ -67,6 +67,6 @@ extension BasicDataSourceRepresentable where Item: Equatable { - returns: The index path for a certain item, or `nil` if there is no such item. */ public func indexPath(for item: Item) -> IndexPath? { - return items.index(of: item).flatMap { IndexPath(item: $0, section: 0) } + return items.firstIndex(of: item).flatMap { IndexPath(item: $0, section: 0) } } } diff --git a/Sources/BasicSupplementaryViewCreator.swift b/Sources/BasicSupplementaryViewCreator.swift index b0791bd..08ad4d1 100644 --- a/Sources/BasicSupplementaryViewCreator.swift +++ b/Sources/BasicSupplementaryViewCreator.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the basic supplementary view creator. /// It manages supplementary views and items to bind to those views. @@ -29,6 +29,7 @@ import Foundation /// - `collectionView(_, sizeForViewOfKind:, at:)` /// /// If you don't want to subclass this class, then you can use `BasicBlockSupplementaryViewCreator` instead. +@MainActor open class BasicSupplementaryViewCreator: NSObject, SupplementaryViewCreator { /// Represents the size of the supplementary views, if you want dynamic size, set this value to nil (which is default). diff --git a/Sources/BatchUpdater.swift b/Sources/BatchUpdater.swift index bbbf2e6..06497eb 100644 --- a/Sources/BatchUpdater.swift +++ b/Sources/BatchUpdater.swift @@ -6,10 +6,9 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation - -protocol BatchUpdater: class { +import UIKit +protocol BatchUpdater: AnyObject { func actualPerformBatchUpdates(_ updates: (() -> Void)?, completion: ((Bool) -> Void)?) } diff --git a/Sources/BlockSelectionHandler.swift b/Sources/BlockSelectionHandler.swift index fe4a1c0..5109b6b 100644 --- a/Sources/BlockSelectionHandler.swift +++ b/Sources/BlockSelectionHandler.swift @@ -13,7 +13,7 @@ import Foundation It's mainly used with `BasicDataSource`. It also can work with `BasicDataSource` nested inside multiple `CompositeDataSource`. You can have one handler for each data source. */ -open class BlockSelectionHandler : DataSourceSelectionHandler { +open class BlockSelectionHandler: DataSourceSelectionHandler { /// Whether to always allow highlighting or not. This variable used when `shouldHighlightBlock` is nil. open var defaultShouldHighlight: Bool = true diff --git a/Sources/CollectionDataSource.swift b/Sources/CollectionDataSource.swift index d6354e9..0cf4c0f 100644 --- a/Sources/CollectionDataSource.swift +++ b/Sources/CollectionDataSource.swift @@ -6,6 +6,8 @@ // Copyright © 2017 mohamede1945. All rights reserved. // +import Foundation + /// Represents the collection data source used as public protocol CollectionDataSource: DataSource { diff --git a/Sources/CompositeSupplementaryViewCreator.swift b/Sources/CompositeSupplementaryViewCreator.swift index e7a96a8..66718ea 100644 --- a/Sources/CompositeSupplementaryViewCreator.swift +++ b/Sources/CompositeSupplementaryViewCreator.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents a supplementary view creator that manages other creators depending on the kind. /// diff --git a/Sources/DataSource.swift b/Sources/DataSource.swift index 1191c3f..1dcad29 100644 --- a/Sources/DataSource.swift +++ b/Sources/DataSource.swift @@ -6,10 +6,10 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// The DataSource protocol is a general data source and delegate protocol for both a UITableViewDataSource/UITableViewDelegate and UICollectionViewDataSource/UICollectionViewDelegate and adopted by an object that mediates the application’™s data model for a view object (e.g. `UITableView` or `UICollectionView`. -@objc public protocol DataSource: class { +@objc public protocol DataSource: AnyObject { /// Asks the data source if it responds to a given selector. /// diff --git a/Sources/DataSourceSelector.swift b/Sources/DataSourceSelector.swift index a7e9189..aee69c7 100644 --- a/Sources/DataSourceSelector.swift +++ b/Sources/DataSourceSelector.swift @@ -6,7 +6,7 @@ // Copyright © 2017 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the data source selectors that can be optional. /// Each case corresponds to a selector in the DataSource. diff --git a/Sources/GeneralCollectionView.swift b/Sources/GeneralCollectionView.swift index 08f2a84..9086cd0 100644 --- a/Sources/GeneralCollectionView.swift +++ b/Sources/GeneralCollectionView.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /** The GeneralCollectionView protocol unifies the interface of the `UICollectionView` and @@ -14,7 +14,7 @@ import Foundation Besides, `CompositeDataSource` has different implementation that allows children data sources to manipulate the `UICollectionView` and/or `UITableView` as if the children data sources are in the same top level first section even if it's in a different section. */ -@objc public protocol GeneralCollectionView: class { +@objc public protocol GeneralCollectionView: AnyObject { /** Represents the underlying scroll view. Use this method if you want to get the diff --git a/Sources/GeneralCollectionViewFocusUpdateContext.swift b/Sources/GeneralCollectionViewFocusUpdateContext.swift index 8e4614f..d877e64 100644 --- a/Sources/GeneralCollectionViewFocusUpdateContext.swift +++ b/Sources/GeneralCollectionViewFocusUpdateContext.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents a focus update context protocol to be something general for `UIFocusUpdateContext`. @available(iOS 9.0, *) diff --git a/Sources/Info.plist b/Sources/Info.plist index 49ca846..ca23c84 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.0.2 + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleVersion diff --git a/Sources/ReusableCell.swift b/Sources/ReusableCell.swift index a0cc341..1ec177f 100644 --- a/Sources/ReusableCell.swift +++ b/Sources/ReusableCell.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /** Represents the reusable cell protocol for all resuable cells mainliy `UITableViewCell` and `UICollectionViewCell`. diff --git a/Sources/ReusableSupplementaryView.swift b/Sources/ReusableSupplementaryView.swift index 24c78a8..c338740 100644 --- a/Sources/ReusableSupplementaryView.swift +++ b/Sources/ReusableSupplementaryView.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the protocol for reusable supplementary view. /// Subclasses can be used as return type for supplementary view of kind methods. @@ -36,7 +36,7 @@ extension UICollectionView { /// - view: The supplementary view class. /// - bundle: An optional bundle parameter. Specify it if the cell is not in the main bundle. /// - kind: The kind of the supplementary view. - open func ds_register(supplementaryViewNib view: UICollectionReusableView.Type, in bundle: Bundle? = nil, forKind kind: String) { + public func ds_register(supplementaryViewNib view: UICollectionReusableView.Type, in bundle: Bundle? = nil, forKind kind: String) { register(UINib(nibName: view.ds_nibName, bundle: bundle), forSupplementaryViewOfKind: kind, withReuseIdentifier: view.ds_reuseId) } @@ -50,7 +50,7 @@ extension UICollectionView { /// - Parameters: /// - view: The supplementary view class. /// - kind: The kind of the supplementary view. - open func ds_register(supplementaryViewClass view: UICollectionReusableView.Type, forKind kind: String) { + public func ds_register(supplementaryViewClass view: UICollectionReusableView.Type, forKind kind: String) { register(view, forSupplementaryViewOfKind: kind, withReuseIdentifier: view.ds_reuseId) } } @@ -68,7 +68,7 @@ extension UITableView { /// - Parameters: /// - view: The supplementary view class. /// - bundle: An optional bundle parameter. Specify it if the cell is not in the main bundle. - open func ds_register(headerFooterNib view: UITableViewHeaderFooterView.Type, in bundle: Bundle? = nil) { + public func ds_register(headerFooterNib view: UITableViewHeaderFooterView.Type, in bundle: Bundle? = nil) { register(UINib(nibName: view.ds_nibName, bundle: bundle), forHeaderFooterViewReuseIdentifier: view.ds_reuseId) } @@ -81,7 +81,7 @@ extension UITableView { /// /// - Parameters: /// - view: The supplementary view class. - open func ds_register(headerFooterClass view: UITableViewHeaderFooterView.Type) { + public func ds_register(headerFooterClass view: UITableViewHeaderFooterView.Type) { register(view, forHeaderFooterViewReuseIdentifier: view.ds_reuseId) } } diff --git a/Sources/ReusableView.swift b/Sources/ReusableView.swift index df6777f..47c9eca 100644 --- a/Sources/ReusableView.swift +++ b/Sources/ReusableView.swift @@ -6,6 +6,8 @@ // Copyright © 2017 mohamede1945. All rights reserved. // +import Foundation + /// The base protocol for any reusable view whether it is a cell or a supplementary view. /// It is used to give default reuse identifier and nib name. @objc public protocol ReusableView { diff --git a/Sources/SegmentedDataSource.swift b/Sources/SegmentedDataSource.swift index f77d088..5d78e2b 100644 --- a/Sources/SegmentedDataSource.swift +++ b/Sources/SegmentedDataSource.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// The composite data source class that is responsible for managing a set of children data sources. /// Delegating requests to the selected child data source to respond. @@ -41,7 +41,7 @@ open class SegmentedDataSource: AbstractDataSource, CollectionDataSource { selectedDataSource = dataSources[newValue] } get { - return dataSources.index { $0 === selectedDataSource } ?? NSNotFound + return dataSources.firstIndex { $0 === selectedDataSource } ?? NSNotFound } } @@ -140,7 +140,7 @@ open class SegmentedDataSource: AbstractDataSource, CollectionDataSource { - returns: The index of the data source. */ open func index(of dataSource: DataSource) -> Int? { - return dataSources.index { $0 === dataSource } + return dataSources.firstIndex { $0 === dataSource } } // MARK: - Responds diff --git a/Sources/SupplementaryViewCreator.swift b/Sources/SupplementaryViewCreator.swift index 639301b..b684a87 100644 --- a/Sources/SupplementaryViewCreator.swift +++ b/Sources/SupplementaryViewCreator.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the protocol for types wanting to handle supplementary view creation and configurations. /// Usually using `BasicSupplementaryViewCreator` or `CompsiteSupplentaryViewCreator` is enough. @@ -15,6 +15,7 @@ import Foundation /// You need to implement at least the following required functions: /// - `collectionView(_, viewOfKind:, at:)` /// - `collectionView(_, sizeForViewOfKind:, at:)` +@MainActor public protocol SupplementaryViewCreator { /// Gets the supplementary view for the passed kind at the specified index path. diff --git a/Sources/UICollectionView+CollectionView.swift b/Sources/UICollectionView+CollectionView.swift index a3f8b30..e75dbdc 100644 --- a/Sources/UICollectionView+CollectionView.swift +++ b/Sources/UICollectionView+CollectionView.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit extension UICollectionView: GeneralCollectionView { diff --git a/Sources/UIKitExtensions.swift b/Sources/UIKitExtensions.swift index 46162c1..4809cfc 100644 --- a/Sources/UIKitExtensions.swift +++ b/Sources/UIKitExtensions.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit extension UITableView.ScrollPosition { init(scrollPosition: UICollectionView.ScrollPosition) { @@ -29,7 +29,7 @@ extension UITableView { - parameter dataSource: The data source to set for the table view. */ - open func ds_useDataSource(_ dataSource: AbstractDataSource) { + public func ds_useDataSource(_ dataSource: AbstractDataSource) { self.dataSource = dataSource self.delegate = dataSource dataSource.ds_reusableViewDelegate = self @@ -43,7 +43,7 @@ extension UICollectionView { - parameter dataSource: The data source to set for the table view. */ - open func ds_useDataSource(_ dataSource: AbstractDataSource) { + public func ds_useDataSource(_ dataSource: AbstractDataSource) { self.dataSource = dataSource self.delegate = dataSource dataSource.ds_reusableViewDelegate = self diff --git a/Sources/UITableView+CollectionView.swift b/Sources/UITableView+CollectionView.swift index 8cb3d67..5c758a6 100644 --- a/Sources/UITableView+CollectionView.swift +++ b/Sources/UITableView+CollectionView.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit extension UITableView: GeneralCollectionView { diff --git a/Sources/UnselectableSelectionHandler.swift b/Sources/UnselectableSelectionHandler.swift index 75b59da..9af92ea 100644 --- a/Sources/UnselectableSelectionHandler.swift +++ b/Sources/UnselectableSelectionHandler.swift @@ -9,7 +9,7 @@ import Foundation /// A selection handler that always disallow selection and highlighting. -public struct UnselectableSelectionHandler : DataSourceSelectionHandler { +public struct UnselectableSelectionHandler: DataSourceSelectionHandler { /// Creates new instance. public init() { diff --git a/Sources/_DataSourcesCollection.swift b/Sources/_DataSourcesCollection.swift index b98e33b..2e93be8 100644 --- a/Sources/_DataSourcesCollection.swift +++ b/Sources/_DataSourcesCollection.swift @@ -14,8 +14,8 @@ private class _DataSourceWrapper: Hashable { self.dataSource = dataSource } - var hashValue: Int { - return Unmanaged.passUnretained(dataSource).toOpaque().hashValue + func hash(into hasher: inout Hasher) { + hasher.combine(Unmanaged.passUnretained(dataSource).toOpaque()) } } @@ -119,7 +119,7 @@ extension _DataSourcesCollection { let wrapper = _DataSourceWrapper(dataSource: dataSource) let exsitingMapping: _DataSourcesCollectionMapping = cast(mappings.dataSourceToMappings[wrapper], message: "Tried to remove a data source that doesn't exist: \(dataSource)") - let index: Int = cast(mappings.array.index(of: exsitingMapping), message: "Tried to remove a data source that doesn't exist: \(dataSource)") + let index: Int = cast(mappings.array.firstIndex(of: exsitingMapping), message: "Tried to remove a data source that doesn't exist: \(dataSource)") mappings.dataSourceToMappings[wrapper] = nil mappings.array.remove(at: index) @@ -159,7 +159,7 @@ extension _DataSourcesCollection { guard let mapping = mapping(of: dataSource) else { return nil } - return mappings.array.index(of: mapping) + return mappings.array.firstIndex(of: mapping) } func mapping(of dataSource: DataSource) -> _DataSourcesCollectionMapping? { diff --git a/Sources/_Utilities.swift b/Sources/_Utilities.swift index ecc58b7..7b9fc36 100644 --- a/Sources/_Utilities.swift +++ b/Sources/_Utilities.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit extension NSObjectProtocol { func cast(_ value: T, file: StaticString = #file, line: UInt = #line) -> U {