From 3b7fe4ae0751f706745e20218d0eb03f779b0055 Mon Sep 17 00:00:00 2001 From: Rudd Date: Wed, 26 Sep 2018 15:29:08 -0400 Subject: [PATCH] use swift 4.2 --- FlowKit.xcodeproj/project.pbxproj | 4 +-- FlowKitManager.podspec | 2 +- .../Collection/CollectionDirector.swift | 16 ++++++------ .../Collection/FlowCollectionDirector.swift | 2 +- Sources/FlowKit/Table/TableAdapter.swift | 2 +- .../FlowKit/Table/TableDirector+Events.swift | 4 +-- .../FlowKit/Table/TableDirector+Support.swift | 12 ++++----- Sources/FlowKit/Table/TableDirector.swift | 26 +++++++++---------- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/FlowKit.xcodeproj/project.pbxproj b/FlowKit.xcodeproj/project.pbxproj index 73a900b..91816c6 100644 --- a/FlowKit.xcodeproj/project.pbxproj +++ b/FlowKit.xcodeproj/project.pbxproj @@ -753,7 +753,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.flowkit.demoapp; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -780,7 +780,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.flowkit.demoapp; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/FlowKitManager.podspec b/FlowKitManager.podspec index 84eadd9..4ed423a 100644 --- a/FlowKitManager.podspec +++ b/FlowKitManager.podspec @@ -13,5 +13,5 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/malcommac/FlowKit.git", :tag => s.version.to_s } s.source_files = "Sources/**/*" s.frameworks = "Foundation" - s.swift_version = "4.0" + s.swift_version = "4.2" end diff --git a/Sources/FlowKit/Collection/CollectionDirector.swift b/Sources/FlowKit/Collection/CollectionDirector.swift index ccbe34d..c31acf8 100644 --- a/Sources/FlowKit/Collection/CollectionDirector.swift +++ b/Sources/FlowKit/Collection/CollectionDirector.swift @@ -502,11 +502,11 @@ public extension CollectionDirector { var identifier: String! switch kind { - case UICollectionElementKindSectionHeader: + case UICollectionView.elementKindSectionHeader: guard let header = section.header else { return UICollectionReusableView() } identifier = self.reusableRegister.registerHeaderFooter(header, type: kind) - case UICollectionElementKindSectionFooter: + case UICollectionView.elementKindSectionFooter: guard let footer = section.footer else { return UICollectionReusableView() } identifier = self.reusableRegister.registerHeaderFooter(footer, type: kind) @@ -522,11 +522,11 @@ public extension CollectionDirector { public func collectionView(_ collectionView: UICollectionView, willDisplaySupplementaryView view: UICollectionReusableView, forElementKind elementKind: String, at indexPath: IndexPath) { switch elementKind { - case UICollectionElementKindSectionHeader: + case UICollectionView.elementKindSectionHeader: let header = (sections[indexPath.section].header as? AbstractCollectionHeaderFooterItem) let _ = header?.dispatch(.willDisplay, type: .header, view: view, section: indexPath.section, collection: collectionView) self.on.willDisplayHeader?( (view,indexPath,collectionView) ) - case UICollectionElementKindSectionFooter: + case UICollectionView.elementKindSectionFooter: let footer = (sections[indexPath.section].footer as? AbstractCollectionHeaderFooterItem) let _ = footer?.dispatch(.willDisplay, type: .footer, view: view, section: indexPath.section, collection: collectionView) self.on.willDisplayFooter?( (view,indexPath,collectionView) ) @@ -539,11 +539,11 @@ public extension CollectionDirector { public func collectionView(_ collectionView: UICollectionView, didEndDisplayingSupplementaryView view: UICollectionReusableView, forElementOfKind elementKind: String, at indexPath: IndexPath) { switch elementKind { - case UICollectionElementKindSectionHeader: + case UICollectionView.elementKindSectionHeader: let header = (sections[indexPath.section].header as? AbstractCollectionHeaderFooterItem) let _ = header?.dispatch(.endDisplay, type: .header, view: view, section: indexPath.section, collection: collectionView) self.on.endDisplayHeader?( (view,indexPath,collectionView) ) - case UICollectionElementKindSectionFooter: + case UICollectionView.elementKindSectionFooter: let footer = (sections[indexPath.section].footer as? AbstractCollectionHeaderFooterItem) let _ = footer?.dispatch(.endDisplay, type: .footer, view: view, section: indexPath.section, collection: collectionView) self.on.endDisplayFooter?( (view,indexPath,collectionView) ) @@ -697,8 +697,8 @@ public extension CollectionDirector { @discardableResult internal func registerHeaderFooter(_ headerFooter: CollectionSectionProtocol, type: String) -> String { let identifier = headerFooter.reuseIdentifier - if (type == UICollectionElementKindSectionHeader && self.headerIDs.contains(identifier)) || - (type == UICollectionElementKindSectionFooter && self.footerIDs.contains(identifier)) { + if (type == UICollectionView.elementKindSectionHeader && self.headerIDs.contains(identifier)) || + (type == UICollectionView.elementKindSectionFooter && self.footerIDs.contains(identifier)) { return identifier } diff --git a/Sources/FlowKit/Collection/FlowCollectionDirector.swift b/Sources/FlowKit/Collection/FlowCollectionDirector.swift index 366298e..1b5332d 100644 --- a/Sources/FlowKit/Collection/FlowCollectionDirector.swift +++ b/Sources/FlowKit/Collection/FlowCollectionDirector.swift @@ -87,7 +87,7 @@ open class FlowCollectionDirector: CollectionDirector, UICollectionViewDelegateF /// Set the section reference starting point. @available(iOS 11.0, *) - public var sectionInsetReference: UICollectionViewFlowLayoutSectionInsetReference { + public var sectionInsetReference: UICollectionViewFlowLayout.SectionInsetReference { set { self.layout?.sectionInsetReference = newValue } get { return self.layout!.sectionInsetReference } } diff --git a/Sources/FlowKit/Table/TableAdapter.swift b/Sources/FlowKit/Table/TableAdapter.swift index e93050b..d6891dd 100644 --- a/Sources/FlowKit/Table/TableAdapter.swift +++ b/Sources/FlowKit/Table/TableAdapter.swift @@ -80,7 +80,7 @@ open class TableAdapter: TableAdapterProtocol case .commitEdit: guard let callback = self.on.commitEdit else { return nil } - return callback(Context(generic: context), (context.param1 as! UITableViewCellEditingStyle)) + return callback(Context(generic: context), (context.param1 as! UITableViewCell.EditingStyle)) case .canMoveRow: guard let callback = self.on.canMoveRow else { return nil } diff --git a/Sources/FlowKit/Table/TableDirector+Events.swift b/Sources/FlowKit/Table/TableDirector+Events.swift index d2106df..d877130 100644 --- a/Sources/FlowKit/Table/TableDirector+Events.swift +++ b/Sources/FlowKit/Table/TableDirector+Events.swift @@ -72,7 +72,7 @@ public extension TableAdapter { public var dequeue : ((EventContext) -> (Void))? = nil public var canEdit: ((EventContext) -> Bool)? = nil - public var commitEdit: ((_ ctx: EventContext, _ commit: UITableViewCellEditingStyle) -> Void)? = nil + public var commitEdit: ((_ ctx: EventContext, _ commit: UITableViewCell.EditingStyle) -> Void)? = nil public var canMoveRow: ((EventContext) -> Bool)? = nil public var moveRow: ((_ ctx: EventContext, _ dest: IndexPath) -> Void)? = nil @@ -97,7 +97,7 @@ public extension TableAdapter { public var willBeginEdit: ((EventContext) -> Void)? = nil public var didEndEdit: ((EventContext) -> Void)? = nil - public var editStyle: ((EventContext) -> UITableViewCellEditingStyle)? = nil + public var editStyle: ((EventContext) -> UITableViewCell.EditingStyle)? = nil public var deleteConfirmTitle: ((EventContext) -> String?)? = nil public var editShouldIndent: ((EventContext) -> Bool)? = nil diff --git a/Sources/FlowKit/Table/TableDirector+Support.swift b/Sources/FlowKit/Table/TableDirector+Support.swift index 49edd97..da821c0 100644 --- a/Sources/FlowKit/Table/TableDirector+Support.swift +++ b/Sources/FlowKit/Table/TableDirector+Support.swift @@ -63,13 +63,13 @@ public enum TableSelectionState { /// Animations used with reload public struct TableReloadAnimations { - public var rowDeletionAnimation: UITableViewRowAnimation = .automatic - public var rowInsertionAnimation: UITableViewRowAnimation = .automatic - public var rowReloadAnimation: UITableViewRowAnimation = .automatic + public var rowDeletionAnimation: UITableView.RowAnimation = .automatic + public var rowInsertionAnimation: UITableView.RowAnimation = .automatic + public var rowReloadAnimation: UITableView.RowAnimation = .automatic - public var sectionDeletionAnimation: UITableViewRowAnimation = .automatic - public var sectionInsertionAnimation: UITableViewRowAnimation = .automatic - public var sectionReloadAnimation: UITableViewRowAnimation = .automatic + public var sectionDeletionAnimation: UITableView.RowAnimation = .automatic + public var sectionInsertionAnimation: UITableView.RowAnimation = .automatic + public var sectionReloadAnimation: UITableView.RowAnimation = .automatic public init() { } diff --git a/Sources/FlowKit/Table/TableDirector.swift b/Sources/FlowKit/Table/TableDirector.swift index ca6259a..1b586e5 100644 --- a/Sources/FlowKit/Table/TableDirector.swift +++ b/Sources/FlowKit/Table/TableDirector.swift @@ -80,11 +80,11 @@ public class TableDirector: NSObject, UITableViewDelegate, UITableViewDataSource self.tableView?.rowHeight = h self.tableView?.estimatedRowHeight = h case .autoLayout(let estimate): - self.tableView?.rowHeight = UITableViewAutomaticDimension + self.tableView?.rowHeight = UITableView.automaticDimension self.tableView?.estimatedRowHeight = estimate case .default: - self.tableView?.rowHeight = UITableViewAutomaticDimension - self.tableView?.estimatedRowHeight = UITableViewAutomaticDimension + self.tableView?.rowHeight = UITableView.automaticDimension + self.tableView?.estimatedRowHeight = UITableView.automaticDimension } } } @@ -428,7 +428,7 @@ public extension TableDirector { public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { let item = (self.sections[section].headerView as? AbstractTableHeaderFooterItem) guard let height = item?.dispatch(.height, type: .header, view: nil, section: section, table: tableView) as? CGFloat else { - return (self.headerHeight ?? UITableViewAutomaticDimension) + return (self.headerHeight ?? UITableView.automaticDimension) } return height } @@ -436,7 +436,7 @@ public extension TableDirector { public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { let item = (self.sections[section].footerView as? AbstractTableHeaderFooterItem) guard let height = item?.dispatch(.height, type: .footer, view: nil, section: section, table: tableView) as? CGFloat else { - return (self.footerHeight ?? UITableViewAutomaticDimension) + return (self.footerHeight ?? UITableView.automaticDimension) } return height } @@ -445,7 +445,7 @@ public extension TableDirector { let item = (self.sections[section].headerView as? AbstractTableHeaderFooterItem) guard let estHeight = item?.dispatch(.estimatedHeight, type: .header, view: nil, section: section, table: tableView) as? CGFloat else { guard let height = item?.dispatch(.height, type: .header, view: nil, section: section, table: tableView) as? CGFloat else { - return (self.headerHeight ?? UITableViewAutomaticDimension) + return (self.headerHeight ?? UITableView.automaticDimension) } return height } @@ -456,7 +456,7 @@ public extension TableDirector { let item = (self.sections[section].footerView as? AbstractTableHeaderFooterItem) guard let height = item?.dispatch(.estimatedHeight,type: .footer, view: nil, section: section, table: tableView) as? CGFloat else { guard let height = item?.dispatch(.height, type: .footer, view: nil, section: section, table: tableView) as? CGFloat else { - return (self.footerHeight ?? UITableViewAutomaticDimension) + return (self.footerHeight ?? UITableView.automaticDimension) } return height } @@ -491,7 +491,7 @@ public extension TableDirector { // Inserting or Deleting Table Rows - public func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { + public func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { let (model,adapter) = self.context(forItemAt: indexPath) adapter.dispatch(.commitEdit, context: InternalContext(model, indexPath, nil, tableView, param1: editingStyle)) } @@ -521,9 +521,9 @@ public extension TableDirector { switch self.rowHeight { case .default: let (model,adapter) = self.context(forItemAt: indexPath) - return (adapter.dispatch(.rowHeight, context: InternalContext(model, indexPath, nil, tableView)) as? CGFloat) ?? UITableViewAutomaticDimension + return (adapter.dispatch(.rowHeight, context: InternalContext(model, indexPath, nil, tableView)) as? CGFloat) ?? UITableView.automaticDimension case .autoLayout(_): - return UITableViewAutomaticDimension + return UITableView.automaticDimension default: return self.tableView!.rowHeight } @@ -531,7 +531,7 @@ public extension TableDirector { public func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { let (model,adapter) = self.context(forItemAt: indexPath) - return ((adapter.dispatch(.rowHeightEstimated, context: InternalContext(model, indexPath, nil, tableView)) as? CGFloat) ?? UITableViewAutomaticDimension) + return ((adapter.dispatch(.rowHeightEstimated, context: InternalContext(model, indexPath, nil, tableView)) as? CGFloat) ?? UITableView.automaticDimension) } public func tableView(_ tableView: UITableView, indentationLevelForRowAt indexPath: IndexPath) -> Int { @@ -597,9 +597,9 @@ public extension TableDirector { adapter.dispatch(.didEndEdit, context: InternalContext(model, indexPath!, nil, tableView)) } - public func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle { + public func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle { let (model,adapter) = self.context(forItemAt: indexPath) - return ((adapter.dispatch(.editStyle, context: InternalContext(model, indexPath, nil, tableView)) as? UITableViewCellEditingStyle) ?? .none) + return ((adapter.dispatch(.editStyle, context: InternalContext(model, indexPath, nil, tableView)) as? UITableViewCell.EditingStyle) ?? .none) } public func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {