From ff79e5ed22a7915a969fe604bde5e469dc171497 Mon Sep 17 00:00:00 2001 From: Vinnie Hesener Date: Tue, 26 Mar 2019 11:05:43 -0500 Subject: [PATCH 1/6] Swift 5 upgrade (#49) Upgraded Swift version to 5.0 --- Closures.podspec.json | 23 ++++++++++++++++++ Supporting/cocoapods/.swift-version | 2 +- Supporting/cocoapods/Closures.podspec.json | 4 +-- Xcode/Closures.xcodeproj/project.pbxproj | 19 +++++++++------ .../xcshareddata/xcschemes/Closures.xcscheme | 2 +- Xcode/Closures/Source/Core.swift | 2 +- Xcode/Closures/Source/UIBarButtonItem.swift | 10 ++++---- Xcode/Closures/Source/UIControl.swift | 2 +- .../Source/UIImagePickerController.swift | 2 +- .../ClosuresDemo.playground/Setup.o | Bin 0 -> 29668 bytes 10 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 Closures.podspec.json create mode 100644 Xcode/Playground/ClosuresDemo.playground/Setup.o diff --git a/Closures.podspec.json b/Closures.podspec.json new file mode 100644 index 0000000..9f959cc --- /dev/null +++ b/Closures.podspec.json @@ -0,0 +1,23 @@ +{ + "name": "Closures", + "version": "0.5", + "summary": "Swifty closures for UIKit and Foundation", + "homepage": "https://github.com/vhesener/Closures", + "screenshots": [ + "https://raw.githubusercontent.com/vhesener/Closures/assets/assets/playground_general.gif", + "https://raw.githubusercontent.com/vhesener/Closures/assets/assets/reference_large.png" + ], + "license": "MIT", + "authors": "Vinnie Hesener", + "platforms": { + "ios": "9.0" + }, + "source": { + "git": "https://github.com/vhesener/Closures.git", + "tag": "v0.5" + }, + "source_files": "Xcode/Closures/Source", + "documentation_url": "https://vhesener.github.io/Closures/", + "description": "Closures is an iOS Framework that adds closure handlers to many of the popular\nUIKit and Foundation classes. Although this framework is a substitute for \nsome Cocoa Touch design patterns, such as Delegation and Data Sources, and \nTarget-Action, the authors make no claim regarding which is a better way to \naccomplish the same type of task. Most of the time it is a matter of style, \npreference, or convenience that will determine if any of these closure extensions \nare beneficial.\n\nWhether you’re a functional purist, dislike a particular API, or simply just \nwant to organize your code a little bit, you might enjoy using this library.", + "pushed_with_swift_version": "5.0" +} diff --git a/Supporting/cocoapods/.swift-version b/Supporting/cocoapods/.swift-version index 8012ebb..6e63660 100644 --- a/Supporting/cocoapods/.swift-version +++ b/Supporting/cocoapods/.swift-version @@ -1 +1 @@ -4.2 \ No newline at end of file +5.0 \ No newline at end of file diff --git a/Supporting/cocoapods/Closures.podspec.json b/Supporting/cocoapods/Closures.podspec.json index 445ab10..7528da5 100644 --- a/Supporting/cocoapods/Closures.podspec.json +++ b/Supporting/cocoapods/Closures.podspec.json @@ -1,6 +1,6 @@ { "name": "Closures", - "version": "0.5", + "version": "0.6", "summary": "Swifty closures for UIKit and Foundation", "homepage": "https://github.com/vhesener/Closures", "screenshots": [ @@ -14,7 +14,7 @@ }, "source": { "git": "https://github.com/vhesener/Closures.git", - "tag": "v0.5" + "tag": "v0.6" }, "source_files": "Xcode/Closures/Source", "documentation_url": "https://vhesener.github.io/Closures/", diff --git a/Xcode/Closures.xcodeproj/project.pbxproj b/Xcode/Closures.xcodeproj/project.pbxproj index 49a9dd1..a6eccd1 100644 --- a/Xcode/Closures.xcodeproj/project.pbxproj +++ b/Xcode/Closures.xcodeproj/project.pbxproj @@ -202,7 +202,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Your Mom"; TargetAttributes = { 3F7620DD1D849B5000E17BF5 = { @@ -219,10 +219,11 @@ }; buildConfigurationList = 3F7620D81D849B5000E17BF5 /* Build configuration list for PBXProject "Closures" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 3F7620D41D849B5000E17BF5; productRefGroup = 3F7620DF1D849B5000E17BF5 /* Products */; @@ -300,6 +301,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++"; @@ -354,7 +356,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_TREAT_WARNINGS_AS_ERRORS = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -365,6 +367,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++"; @@ -411,7 +414,7 @@ SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_TREAT_WARNINGS_AS_ERRORS = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -438,7 +441,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -460,7 +463,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -473,7 +476,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.vhesener.ClosuresTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -486,7 +489,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.vhesener.ClosuresTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Xcode/Closures.xcodeproj/xcshareddata/xcschemes/Closures.xcscheme b/Xcode/Closures.xcodeproj/xcshareddata/xcschemes/Closures.xcscheme index 92cb476..6a00b26 100644 --- a/Xcode/Closures.xcodeproj/xcshareddata/xcschemes/Closures.xcscheme +++ b/Xcode/Closures.xcodeproj/xcshareddata/xcschemes/Closures.xcscheme @@ -1,6 +1,6 @@ : delegates: inout Set>, bind: (_ delegator: Delegator, _ delegate: Delegate) -> Void, with updateHandler: (_ wrapper: DelegateWrapper) -> Void) { - let wrapper = self.wrapper(delegator: delegator, delegate: delegate, delegates: &delegates, bind: bind) + let wrapper = self.wrapper(delegator: delegator, delegate: delegate(), delegates: &delegates, bind: bind) updateHandler(wrapper) bind(delegator, wrapper.delegate) } diff --git a/Xcode/Closures/Source/UIBarButtonItem.swift b/Xcode/Closures/Source/UIBarButtonItem.swift index 9a0f1c4..57df48f 100644 --- a/Xcode/Closures/Source/UIBarButtonItem.swift +++ b/Xcode/Closures/Source/UIBarButtonItem.swift @@ -33,7 +33,7 @@ public extension UIBarButtonItem { * parameter style: The `UIBarButtonItemStyle` of the button * parameter handler: The closure that is called when the button is tapped */ - public convenience init(image: UIImage?, style: UIBarButtonItem.Style, handler: @escaping () -> Void) { + convenience init(image: UIImage?, style: UIBarButtonItem.Style, handler: @escaping () -> Void) { self.init(image: image, style: style, target: nil, action: nil) onTap(handler: handler) } @@ -49,7 +49,7 @@ public extension UIBarButtonItem { * parameter handler: The closure that is called when the button is tapped */ @available(iOS 5.0, *) - public convenience init(image: UIImage?, landscapeImagePhone: UIImage?, style: UIBarButtonItem.Style, handler: @escaping () -> Void) { + convenience init(image: UIImage?, landscapeImagePhone: UIImage?, style: UIBarButtonItem.Style, handler: @escaping () -> Void) { self.init(image: image, landscapeImagePhone: landscapeImagePhone, style: style, target: nil, action: nil) onTap(handler: handler) } @@ -63,7 +63,7 @@ public extension UIBarButtonItem { * parameter style: The `UIBarButtonItemStyle` of the button * parameter handler: The closure that is called when the button is tapped */ - public convenience init(title: String?, style: UIBarButtonItem.Style, handler: @escaping () -> Void) { + convenience init(title: String?, style: UIBarButtonItem.Style, handler: @escaping () -> Void) { self.init(title: title, style: style, target: nil, action: nil) onTap(handler: handler) } @@ -76,7 +76,7 @@ public extension UIBarButtonItem { * parameter barButtonSystemItem: The `UIBarButtonSystemItem` to be used for the button * parameter handler: The closure that is called when the button is tapped */ - public convenience init(barButtonSystemItem systemItem: UIBarButtonItem.SystemItem, handler: @escaping () -> Void) { + convenience init(barButtonSystemItem systemItem: UIBarButtonItem.SystemItem, handler: @escaping () -> Void) { self.init(barButtonSystemItem: systemItem, target: nil, action: nil) onTap(handler: handler) } @@ -98,7 +98,7 @@ public extension UIBarButtonItem { * parameter handler: The closure that will be called when the tap is recognized. */ - public func onTap(handler: @escaping () -> Void) { + func onTap(handler: @escaping () -> Void) { target = self action = #selector(UIBarButtonItem.buttonTapped) NotificationCenter.selfObserve(name: .barButtonItemTapped, target: self) { button, userInfo in diff --git a/Xcode/Closures/Source/UIControl.swift b/Xcode/Closures/Source/UIControl.swift index 0fb831a..50a6b92 100644 --- a/Xcode/Closures/Source/UIControl.swift +++ b/Xcode/Closures/Source/UIControl.swift @@ -21,7 +21,7 @@ import UIKit fileprivate extension UIControl { - fileprivate func _onChange( + func _onChange( callerHandler: @escaping (_ value: ValueType) -> (Void), valueHandler: @escaping (_ control: ControlType) -> (ValueType)) { on(.valueChanged) { control, _ in diff --git a/Xcode/Closures/Source/UIImagePickerController.swift b/Xcode/Closures/Source/UIImagePickerController.swift index 62e38f4..e1e145b 100644 --- a/Xcode/Closures/Source/UIImagePickerController.swift +++ b/Xcode/Closures/Source/UIImagePickerController.swift @@ -325,7 +325,7 @@ extension UIImagePickerController.MediaFilter: ExpressibleByIntegerLiteral { } fileprivate extension CFString { - fileprivate var mediaFilter: UIImagePickerController.MediaFilter { + var mediaFilter: UIImagePickerController.MediaFilter { switch self { case kUTTypeImage: return .image diff --git a/Xcode/Playground/ClosuresDemo.playground/Setup.o b/Xcode/Playground/ClosuresDemo.playground/Setup.o new file mode 100644 index 0000000000000000000000000000000000000000..2672ff0c3e60016dfe92ebddb5e5b58be2bb3849 GIT binary patch literal 29668 zcmeHwe|#I&mG2~k#33Ozv?+#?MnGu8wh%dq69>{_*;X=6C!$lT|{l$<5N z?++%D@o+~gC))L^WO*MaTjA=5JZl^C^=l3!1Cp2i+VvY+A@h19C{wGXeq+$jDwnfS zK5-!2k}UTpyJ8_U*{+}SYRUOsF3^dFld6-D$GX|t%kqMOSTYq4+2x&Kc}*;DZ5hj{ zRg}dt%_c7x?MP%D(B9tq56VJqY`;OsqyA`uJQ@S`3;kh}m+LPhACe`$$_0zoNV~1v zV(VDWH|^IF4n>;Vo9*pwUMU$J%>N+dk=>3!9uH4jdxig*O4{4o&+ zR9_ipd1fb;XY&f(aeN6z0*OQqUBd{RbY(W=`rjf&X_Gnf?`l9PJ~T%ua}hD@6CbMYTG6fp(fB^4J`(6^jYm@*&E8Zj7LA($ zi})S*P~Tk}5wX!%yEUAXPkLMOtE2IdVwAJhW0p1YE#)>*^?_tK+Cg>U06g`EqbQREtblw~f#M;8a#I$m(JTu6trSWLw7t#lEOdf;J zfg6jx>q5yug!1Sz^tIX9w5ra?g_kM7w-m_0X9~h%CNor1%>5n0nGZO6;oUnbz!qD;R>YwuCDbm!T#XI1TR4B*lF+5i)>#N(=7Ii>2cO11YyvD*8}q^kW^z2*&7 zdt23y5}&FaYZ8F8bfdUCTrZ$c1^fwODorsJQjAlISveaqwc2>?HIp9gIMfoY&^xB; z^t#I0-p7k;dtaW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Tkm%|Nx>_*#RbZRc90_-X*4!3Nl(*1=W__p=FKJJPx?I)H8tFV(DmZI| zThNVt0o2viSe4w=;wlsE{B5 zTd229>pES+PGx1Ojs$-H7{)(0((I~cF8t`NfJd8U-D_#7>#E9^DZ61!NA!TJx@(iD z(HmG@;TJP}AQ`GkwX}rdz7G0*DQ`~8%G*J;r`oFn_-7*U%Ke0MonOq`RnA?sx(&l! zr6g}zEE?{@Sn_+l*)+=!2Hk7c;h&knzje|K@$~!5NLQ6usBel#+q1DALqKd{yy73y z!ES`)n`5<*P04gs+i%(>BHW+p{INP&ywFb>yiLQBkr+~vut>bG}9?(+VB|6i1KpBgw2dhGv>(bykXt&2%Z^g$lvgY5;^TH zWW<`co?wT?7**#^JdR5wJkBh@-gWht{aL@aQ*oGux2aLVRw zP71*}7AR!?`a&}zsbp2i`0;UBIZm|XIhu?YWoufZ@oapRQzK#&2}qPxU^kB+gNt7( z*I}E2jfdaAwgtZ?UrW=MoVpU_+d?>u*q$g`jXiNP9F&rG`CY43Zz_Qw9CswwtllMM zo+}vt-5sS7=;0j)w>G-BMr5aABfO^F##)H+oSo#4 z)#dkQL4TedTT6}AwQavT&pJJJeSW_qN4r9m=E^GY3voDux2A&r2_JfA!0NqS7)_n9 zpJ@v^+1M;B+2QYW)xd{Rv6CowAdbPP4 z%vlFgaOvFa_r~xS=W3g7F(bXR+P;$aH?-bXZk1g|RIYZEl5I-a+B^o4G_(FxXl9PG wHDEE0s;*nZ$76hOfPXG16kly+C?hIY&-|3KvU68U9A-b2InQ0diSM`m9j}ChkN^Mx literal 0 HcmV?d00001 From 9423f896b7819433d5df8806baa551f65a1e2fa0 Mon Sep 17 00:00:00 2001 From: Vinnie Hesener Date: Tue, 26 Mar 2019 11:07:01 -0500 Subject: [PATCH 2/6] Updated podspec --- Closures.podspec.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Closures.podspec.json b/Closures.podspec.json index 9f959cc..f6095f0 100644 --- a/Closures.podspec.json +++ b/Closures.podspec.json @@ -1,6 +1,6 @@ { "name": "Closures", - "version": "0.5", + "version": "0.6", "summary": "Swifty closures for UIKit and Foundation", "homepage": "https://github.com/vhesener/Closures", "screenshots": [ @@ -14,7 +14,7 @@ }, "source": { "git": "https://github.com/vhesener/Closures.git", - "tag": "v0.5" + "tag": "v0.6" }, "source_files": "Xcode/Closures/Source", "documentation_url": "https://vhesener.github.io/Closures/", From c8242ca7fdc9e396204f46cfca9b29258bb4c553 Mon Sep 17 00:00:00 2001 From: Vinnie Hesener Date: Fri, 21 Jun 2019 22:09:33 -0500 Subject: [PATCH 3/6] Version support description changed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35eb425..e37242c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Whether you're a functional purist, dislike a particular API, or simply just want to organize your code a little bit, you might enjoy using this library. > ***note***
-> `Closures` currently only supports projects written in **Swift 4.0**+. +> `Closures` currently only supports projects written in **Swift 5.0**+. *** ## [Usage Overview](#usage-overview) From 775d51ba083e21840950334a759178576775da3a Mon Sep 17 00:00:00 2001 From: Ian G Date: Wed, 31 Jul 2019 21:16:06 -0400 Subject: [PATCH 4/6] Create SwiftPM Package.swift --- Package.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..e1a1744 --- /dev/null +++ b/Package.swift @@ -0,0 +1,14 @@ +// swift-tools-version:5.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. +import PackageDescription + +let package = Package( + name: "Closures", + products: [ + .library(name: "Closures", targets: ["Closures"]) + ], + dependencies: [], + targets: [ + .target(name: "Closures", path: "Xcode/Closures") + ] +) From 030bff553354c95029499beecf3b79e6879806bd Mon Sep 17 00:00:00 2001 From: Ian Grossberg Date: Wed, 31 Jul 2019 21:31:53 -0400 Subject: [PATCH 5/6] Specify appropriate @available --- Xcode/Closures.xcodeproj/project.pbxproj | 6 ++-- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++ .../xcshareddata/xcschemes/Closures.xcscheme | 28 ++++++++----------- Xcode/Closures/Source/Core.swift | 4 +++ Xcode/Closures/Source/UICollectionView.swift | 4 +++ Xcode/Closures/Source/UIControl.swift | 15 ++++++++++ .../Closures/Source/UIGestureRecognizer.swift | 3 ++ .../Source/UIImagePickerController.swift | 7 +++++ Xcode/Closures/Source/UIPickerView.swift | 4 +++ Xcode/Closures/Source/UIScrollView.swift | 3 ++ Xcode/Closures/Source/UITableView.swift | 5 ++++ 11 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 Xcode/Closures.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Xcode/Closures.xcodeproj/project.pbxproj b/Xcode/Closures.xcodeproj/project.pbxproj index a6eccd1..f173d25 100644 --- a/Xcode/Closures.xcodeproj/project.pbxproj +++ b/Xcode/Closures.xcodeproj/project.pbxproj @@ -202,7 +202,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1100; ORGANIZATIONNAME = "Your Mom"; TargetAttributes = { 3F7620DD1D849B5000E17BF5 = { @@ -426,7 +426,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -449,7 +449,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/Xcode/Closures.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Xcode/Closures.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Xcode/Closures.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Xcode/Closures.xcodeproj/xcshareddata/xcschemes/Closures.xcscheme b/Xcode/Closures.xcodeproj/xcshareddata/xcschemes/Closures.xcscheme index 6a00b26..d4c233a 100644 --- a/Xcode/Closures.xcodeproj/xcshareddata/xcschemes/Closures.xcscheme +++ b/Xcode/Closures.xcodeproj/xcshareddata/xcschemes/Closures.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + + + + @@ -40,17 +49,6 @@ - - - - - - - - : NSObject { weak var delegator: Delegator? let delegate: Delegate @@ -75,6 +78,7 @@ class DelegateWrapper: } } + @available(iOS 9.0, *) public static func update(_ delegator: Delegator, delegate: @autoclosure () -> Delegate, delegates: inout Set>, diff --git a/Xcode/Closures/Source/UICollectionView.swift b/Xcode/Closures/Source/UICollectionView.swift index a032b48..2b3e7e5 100644 --- a/Xcode/Closures/Source/UICollectionView.swift +++ b/Xcode/Closures/Source/UICollectionView.swift @@ -23,6 +23,7 @@ import UIKit /// :nodoc: private let jzyBug = 0 // Prevent the license header from showing up in Jazzy Docs for UICollectionView +@available(iOS 9.0, *) extension UICollectionView { // MARK: Common Array Usage /** @@ -110,6 +111,7 @@ extension UICollectionView { } } +@available(iOS 9.0, *) class CollectionViewDelegate: ScrollViewDelegate, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { fileprivate static var delegates = Set>() @@ -355,6 +357,7 @@ class CollectionViewDelegate: ScrollViewDelegate, UICollectionViewDelegateFlowLa } } +@available(iOS 9.0, *) extension UICollectionView { // MARK: Delegate and DataSource Overrides /** @@ -755,6 +758,7 @@ extension UICollectionView { } } +@available(iOS 9.0, *) extension UICollectionView { @discardableResult @objc override func update(handler: (_ delegate: CollectionViewDelegate) -> Void) -> Self { diff --git a/Xcode/Closures/Source/UIControl.swift b/Xcode/Closures/Source/UIControl.swift index 50a6b92..0f44628 100644 --- a/Xcode/Closures/Source/UIControl.swift +++ b/Xcode/Closures/Source/UIControl.swift @@ -20,6 +20,7 @@ import UIKit +@available(iOS 9.0, *) fileprivate extension UIControl { func _onChange( callerHandler: @escaping (_ value: ValueType) -> (Void), @@ -33,6 +34,7 @@ fileprivate extension UIControl { } } +@available(iOS 9.0, *) extension UIControl { public typealias EventHandler = (_ sender: UIControl, _ forEvent: UIEvent?) -> Void /** @@ -166,6 +168,7 @@ extension UIControl { } } +@available(iOS 9.0, *) extension UIControl { /** Provides the proper internal selector to call for the type of UIControlEvent @@ -223,6 +226,7 @@ extension UIControl { } } +@available(iOS 9.0, *) extension UIButton { // MARK: Common Events /** @@ -251,6 +255,7 @@ extension UIButton { } } +@available(iOS 9.0, *) extension UITextField { // MARK: Common Events /** @@ -337,6 +342,7 @@ extension UITextField { } } +@available(iOS 9.0, *) extension UITextField { // MARK: Delegate Overrides /** @@ -457,6 +463,7 @@ extension UITextField { } } +@available(iOS 9.0, *) extension UITextField: DelegatorProtocol { @discardableResult fileprivate func update(handler: (_ delegate: TextFieldDelegate) -> Void) -> Self { @@ -488,11 +495,13 @@ extension UITextField: DelegatorProtocol { } #if DEBUG +@available(iOS 9.0, *) var textFieldDelegates: Set { return TextFieldDelegate.delegates } #endif +@available(iOS 9.0, *) fileprivate final class TextFieldDelegate: NSObject, UITextFieldDelegate, DelegateProtocol { fileprivate static var delegates = Set>() @@ -557,6 +566,7 @@ fileprivate final class TextFieldDelegate: NSObject, UITextFieldDelegate, Delega } } +@available(iOS 9.0, *) extension UISwitch { // MARK: Common Events /** @@ -576,6 +586,7 @@ extension UISwitch { } } +@available(iOS 9.0, *) extension UISlider { // MARK: Common Events /** @@ -595,6 +606,7 @@ extension UISlider { } } +@available(iOS 9.0, *) extension UISegmentedControl { // MARK: Common Events /** @@ -614,6 +626,7 @@ extension UISegmentedControl { } } +@available(iOS 9.0, *) extension UIStepper { // MARK: Common Events /** @@ -633,6 +646,7 @@ extension UIStepper { } } +@available(iOS 9.0, *) extension UIPageControl { // MARK: Common Events /** @@ -652,6 +666,7 @@ extension UIPageControl { } } +@available(iOS 9.0, *) extension UIDatePicker { // MARK: Common Events /** diff --git a/Xcode/Closures/Source/UIGestureRecognizer.swift b/Xcode/Closures/Source/UIGestureRecognizer.swift index 75705bb..431a3d5 100644 --- a/Xcode/Closures/Source/UIGestureRecognizer.swift +++ b/Xcode/Closures/Source/UIGestureRecognizer.swift @@ -343,6 +343,7 @@ extension UIView { } } +@available(iOS 9.0, *) fileprivate final class GestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate, DelegateProtocol { static var delegates = Set>() @@ -396,6 +397,7 @@ fileprivate final class GestureRecognizerDelegate: NSObject, UIGestureRecognizer } } +@available(iOS 9.0, *) extension UIGestureRecognizer { // MARK: Delegate Overrides /** @@ -471,6 +473,7 @@ extension UIGestureRecognizer { } } +@available(iOS 9.0, *) extension UIGestureRecognizer: DelegatorProtocol { @discardableResult fileprivate func update(handler: (_ delegate: GestureRecognizerDelegate) -> Void) -> Self { diff --git a/Xcode/Closures/Source/UIImagePickerController.swift b/Xcode/Closures/Source/UIImagePickerController.swift index e1e145b..af14a5b 100644 --- a/Xcode/Closures/Source/UIImagePickerController.swift +++ b/Xcode/Closures/Source/UIImagePickerController.swift @@ -22,6 +22,7 @@ import UIKit import MobileCoreServices import PhotosUI +@available(iOS 9.0, *) fileprivate final class ImagePickerControllerDelegate: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate, DelegateProtocol { static var delegates = Set>() @@ -49,6 +50,7 @@ fileprivate final class ImagePickerControllerDelegate: NSObject, UIImagePickerCo } } +@available(iOS 9.0, *) extension UIImagePickerController { // MARK: Convenient Presenting /** @@ -169,6 +171,7 @@ extension UIImagePickerController { } } +@available(iOS 9.0, *) extension UIImagePickerController { // MARK: Delegate Overrides /** @@ -196,6 +199,7 @@ extension UIImagePickerController { } } +@available(iOS 9.0, *) extension UIImagePickerController { // MARK: Helper Types /** @@ -317,6 +321,7 @@ extension UIImagePickerController { } } +@available(iOS 9.0, *) extension UIImagePickerController.MediaFilter: ExpressibleByIntegerLiteral { /// :nodoc: public init(integerLiteral value: Int) { @@ -324,6 +329,7 @@ extension UIImagePickerController.MediaFilter: ExpressibleByIntegerLiteral { } } +@available(iOS 9.0, *) fileprivate extension CFString { var mediaFilter: UIImagePickerController.MediaFilter { switch self { @@ -337,6 +343,7 @@ fileprivate extension CFString { } } +@available(iOS 9.0, *) extension UIImagePickerController: DelegatorProtocol { @discardableResult fileprivate func update(handler: (_ delegate: ImagePickerControllerDelegate) -> Void) -> Self { diff --git a/Xcode/Closures/Source/UIPickerView.swift b/Xcode/Closures/Source/UIPickerView.swift index 878c2be..7aa16b4 100644 --- a/Xcode/Closures/Source/UIPickerView.swift +++ b/Xcode/Closures/Source/UIPickerView.swift @@ -20,6 +20,7 @@ import UIKit +@available(iOS 9.0, *) fileprivate final class PickerViewDelegate: NSObject, UIPickerViewDelegate, UIPickerViewDataSource, DelegateProtocol { static var delegates = Set>() @@ -87,6 +88,7 @@ fileprivate final class PickerViewDelegate: NSObject, UIPickerViewDelegate, UIPi } } +@available(iOS 9.0, *) extension UIPickerView { // MARK: Common Array Usage /** @@ -422,6 +424,7 @@ extension UIPickerView { } } +@available(iOS 9.0, *) extension UIPickerView { // MARK: Delegate and DataSource Overrides /** @@ -521,6 +524,7 @@ extension UIPickerView { } } +@available(iOS 9.0, *) extension UIPickerView: DelegatorProtocol { @discardableResult fileprivate func update(handler: (_ delegate: PickerViewDelegate) -> Void) -> Self { diff --git a/Xcode/Closures/Source/UIScrollView.swift b/Xcode/Closures/Source/UIScrollView.swift index b8a3ad1..3e250ce 100644 --- a/Xcode/Closures/Source/UIScrollView.swift +++ b/Xcode/Closures/Source/UIScrollView.swift @@ -20,6 +20,7 @@ import UIKit +@available(iOS 9.0, *) class ScrollViewDelegate: NSObject, UIScrollViewDelegate, DelegateProtocol { fileprivate static var delegates = Set>() @@ -129,6 +130,7 @@ class ScrollViewDelegate: NSObject, UIScrollViewDelegate, DelegateProtocol { } } +@available(iOS 9.0, *) extension UIScrollView { // MARK: Delegate Overrides /** @@ -300,6 +302,7 @@ extension UIScrollView { } } +@available(iOS 9.0, *) extension UIScrollView: DelegatorProtocol { @discardableResult @objc func update(handler: (_ delegate: ScrollViewDelegate) -> Void) -> Self { diff --git a/Xcode/Closures/Source/UITableView.swift b/Xcode/Closures/Source/UITableView.swift index 058eca6..1ca7d4f 100644 --- a/Xcode/Closures/Source/UITableView.swift +++ b/Xcode/Closures/Source/UITableView.swift @@ -23,6 +23,7 @@ import UIKit /// :nodoc: private let jzyBug = 0 // Prevent the license header from showing up in Jazzy Docs for UITableView +@available(iOS 9.0, *) extension UITableView { // MARK: Common Array Usage /** @@ -241,6 +242,7 @@ extension UITableView { } } +@available(iOS 9.0, *) class TableViewDelegate: ScrollViewDelegate, UITableViewDelegate, UITableViewDataSource { fileprivate static var delegates = Set>() @@ -440,6 +442,7 @@ class TableViewDelegate: ScrollViewDelegate, UITableViewDelegate, UITableViewDat } } +@available(iOS 9.0, *) extension TableViewDelegate { func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { willDisplay?(cell, indexPath) @@ -648,6 +651,7 @@ extension TableViewDelegate { } } +@available(iOS 9.0, *) extension UITableView { // MARK: Delegate and DataSource Overrides /** @@ -1263,6 +1267,7 @@ extension UITableView { } } +@available(iOS 9.0, *) extension UITableView { @discardableResult @objc override func update(handler: (_ delegate: TableViewDelegate) -> Void) -> Self { From dad3dfb8195da3b8aec086430ea6aa0a3c81751b Mon Sep 17 00:00:00 2001 From: Ian Grossberg Date: Wed, 31 Jul 2019 22:51:50 -0400 Subject: [PATCH 6/6] Updated for iOS 13 --- Xcode/Closures/Source/UITableView.swift | 112 ++++++++++++++++-- .../ClosuresTests/UICollectionViewTests.swift | 10 +- Xcode/ClosuresTests/UITableViewTests.swift | 75 +++++++++--- 3 files changed, 167 insertions(+), 30 deletions(-) diff --git a/Xcode/Closures/Source/UITableView.swift b/Xcode/Closures/Source/UITableView.swift index 1ca7d4f..9dd0161 100644 --- a/Xcode/Closures/Source/UITableView.swift +++ b/Xcode/Closures/Source/UITableView.swift @@ -270,14 +270,18 @@ class TableViewDelegate: ScrollViewDelegate, UITableViewDelegate, UITableViewDat fileprivate var didDeselectRowAt: ((_ indexPath: IndexPath) -> Void)? fileprivate var editingStyleForRowAt: ((_ indexPath: IndexPath) -> UITableViewCell.EditingStyle)? fileprivate var titleForDeleteConfirmationButtonForRowAt: ((_ indexPath: IndexPath) -> String?)? + @available(iOS, deprecated: 13.0) fileprivate var editActionsForRowAt: ((_ indexPath: IndexPath) -> [UITableViewRowAction]?)? fileprivate var shouldIndentWhileEditingRowAt: ((_ indexPath: IndexPath) -> Bool)? fileprivate var willBeginEditingRowAt: ((_ indexPath: IndexPath) -> Void)? fileprivate var didEndEditingRowAt: ((_ indexPath: IndexPath?) -> Void)? fileprivate var targetIndexPathForMoveFromRowAt: ((_ sourceIndexPath: IndexPath, _ proposedDestinationIndexPath: IndexPath) -> IndexPath)? fileprivate var indentationLevelForRowAt: ((_ indexPath: IndexPath) -> Int)? + @available(iOS, deprecated: 13.0) fileprivate var shouldShowMenuForRowAt: ((_ indexPath: IndexPath) -> Bool)? + @available(iOS, deprecated: 13.0) fileprivate var canPerformAction: ((_ action: Selector, _ indexPath: IndexPath, _ sender: Any?) -> Bool)? + @available(iOS, deprecated: 13.0) fileprivate var performAction: ((_ action: Selector, _ indexPath: IndexPath, _ sender: Any?) -> Void)? fileprivate var canFocusRowAt: ((_ indexPath: IndexPath) -> Bool)? fileprivate var shouldUpdateFocus: ((_ context: UITableViewFocusUpdateContext) -> Bool)? @@ -324,6 +328,38 @@ class TableViewDelegate: ScrollViewDelegate, UITableViewDelegate, UITableViewDat _shouldSpringLoadRowAt = newValue } } + private var _shouldBeginMultipleSelectionInteractionAt: Any? + @available(iOS 13.0, *) + fileprivate var shouldBeginMultipleSelectionInteractionAt: ((_ indexPath: IndexPath) -> Bool)? { + get { + return _shouldBeginMultipleSelectionInteractionAt as? (_ indexPath: IndexPath) -> Bool + } + set { + _shouldBeginMultipleSelectionInteractionAt = newValue + } + } + + private var _didBeginMultipleSelectionInteractionAt: Any? + @available(iOS 13.0, *) + fileprivate var didBeginMultipleSelectionInteractionAt: ((_ indexPath: IndexPath) -> Void)? { + get { + return _didBeginMultipleSelectionInteractionAt as? (_ indexPath: IndexPath) -> Void + } + set { + _didBeginMultipleSelectionInteractionAt = newValue + } + } + + private var _didEndMultipleSelectionInteraction: Any? + @available(iOS 13.0, *) + fileprivate var didEndMultipleSelectionInteraction: (() -> Void)? { + get { + return _didEndMultipleSelectionInteraction as? () -> Void + } + set { + _didEndMultipleSelectionInteraction = newValue + } + } override func responds(to aSelector: Selector!) -> Bool { if #available(iOS 11, *) { @@ -338,6 +374,33 @@ class TableViewDelegate: ScrollViewDelegate, UITableViewDelegate, UITableViewDat break } } + + if #available(iOS 13, *) { + switch aSelector { + case #selector(TableViewDelegate.tableView(_:shouldBeginMultipleSelectionInteractionAt:)): + return _shouldBeginMultipleSelectionInteractionAt != nil + case #selector(TableViewDelegate.tableView(_:didBeginMultipleSelectionInteractionAt:)): + return _didBeginMultipleSelectionInteractionAt != nil + case #selector(TableViewDelegate.tableView(_:didEndEditingRowAt:)): + return _didEndMultipleSelectionInteraction != nil + default: + break + } + } else { + switch aSelector { + case #selector(TableViewDelegate.tableView(_:editActionsForRowAt:)): + return editActionsForRowAt != nil + case #selector(TableViewDelegate.tableView(_:shouldShowMenuForRowAt:)): + return shouldShowMenuForRowAt != nil + case #selector(TableViewDelegate.tableView(_:canPerformAction:forRowAt:withSender:)): + return canPerformAction != nil + case #selector(TableViewDelegate.tableView(_:performAction:forRowAt:withSender:)): + return performAction != nil + + default: + break + } + } switch aSelector { case #selector(TableViewDelegate.tableView(_:willDisplay:forRowAt:)): @@ -388,8 +451,6 @@ class TableViewDelegate: ScrollViewDelegate, UITableViewDelegate, UITableViewDat return editingStyleForRowAt != nil case #selector(TableViewDelegate.tableView(_:titleForDeleteConfirmationButtonForRowAt:)): return titleForDeleteConfirmationButtonForRowAt != nil - case #selector(TableViewDelegate.tableView(_:editActionsForRowAt:)): - return editActionsForRowAt != nil case #selector(TableViewDelegate.tableView(_:shouldIndentWhileEditingRowAt:)): return shouldIndentWhileEditingRowAt != nil case #selector(TableViewDelegate.tableView(_:willBeginEditingRowAt:)): @@ -400,12 +461,6 @@ class TableViewDelegate: ScrollViewDelegate, UITableViewDelegate, UITableViewDat return targetIndexPathForMoveFromRowAt != nil case #selector(TableViewDelegate.tableView(_:indentationLevelForRowAt:)): return indentationLevelForRowAt != nil - case #selector(TableViewDelegate.tableView(_:shouldShowMenuForRowAt:)): - return shouldShowMenuForRowAt != nil - case #selector(TableViewDelegate.tableView(_:canPerformAction:forRowAt:withSender:)): - return canPerformAction != nil - case #selector(TableViewDelegate.tableView(_:canPerformAction:forRowAt:withSender:)): - return performAction != nil case #selector(TableViewDelegate.tableView(_:canFocusRowAt:)): return canFocusRowAt != nil case #selector(TableViewDelegate.tableView(_:shouldUpdateFocusIn:)): @@ -540,6 +595,7 @@ extension TableViewDelegate { return titleForDeleteConfirmationButtonForRowAt?(indexPath) ?? Bundle(identifier: "com.apple.UIKit")?.localizedString(forKey: "Delete", value: nil, table: nil) } + @available(iOS, deprecated: 13.0) func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { return editActionsForRowAt?(indexPath) ?? nil } @@ -564,14 +620,17 @@ extension TableViewDelegate { return indentationLevelForRowAt?(indexPath) ?? 0 } + @available(iOS, deprecated: 13.0) func tableView(_ tableView: UITableView, shouldShowMenuForRowAt indexPath: IndexPath) -> Bool { return shouldShowMenuForRowAt?(indexPath) ?? false } + @available(iOS, deprecated: 13.0) func tableView(_ tableView: UITableView, canPerformAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) -> Bool { return canPerformAction?(action, indexPath, sender) ?? false } + @available(iOS, deprecated: 13.0) func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) { performAction?(action, indexPath, sender) } @@ -649,6 +708,21 @@ extension TableViewDelegate { func tableView(_ tableView: UITableView, shouldSpringLoadRowAt indexPath: IndexPath, with context: UISpringLoadedInteractionContext) -> Bool { return shouldSpringLoadRowAt?(indexPath, context) ?? true } + + @available(iOS 13, *) + func tableView(_ tableView: UITableView, shouldBeginMultipleSelectionInteractionAt indexPath: IndexPath) -> Bool { + return shouldBeginMultipleSelectionInteractionAt?(indexPath) ?? false + } + + @available(iOS 13, *) + func tableView(_ tableView: UITableView, didBeginMultipleSelectionInteractionAt indexPath: IndexPath) { + didBeginMultipleSelectionInteractionAt?(indexPath) + } + + @available(iOS 13, *) + func tableViewDidEndMultipleSelectionInteraction(_ tableView: UITableView) { + didEndMultipleSelectionInteraction?() + } } @available(iOS 9.0, *) @@ -949,6 +1023,7 @@ extension UITableView { * returns: itself so you can daisy chain the other delegate calls */ + @available(iOS, deprecated: 13.0) @discardableResult public func editActionsForRowAt(handler: @escaping (_ indexPath: IndexPath) -> [UITableViewRowAction]?) -> Self { return update { $0.editActionsForRowAt = handler } @@ -1021,6 +1096,7 @@ extension UITableView { * returns: itself so you can daisy chain the other delegate calls */ + @available(iOS, deprecated: 13.0) @discardableResult public func shouldShowMenuForRowAt(handler: @escaping (_ indexPath: IndexPath) -> Bool) -> Self { return update { $0.shouldShowMenuForRowAt = handler } @@ -1033,6 +1109,7 @@ extension UITableView { * returns: itself so you can daisy chain the other delegate calls */ + @available(iOS, deprecated: 13.0) @discardableResult public func canPerformAction(handler: @escaping (_ action: Selector, _ indexPath: IndexPath, _ sender: Any?) -> Bool) -> Self { return update { $0.canPerformAction = handler } @@ -1045,6 +1122,7 @@ extension UITableView { * returns: itself so you can daisy chain the other delegate calls */ + @available(iOS, deprecated: 13.0) @discardableResult public func performAction(handler: @escaping (_ action: Selector, _ indexPath: IndexPath, _ sender: Any?) -> Void) -> Self { return update { $0.performAction = handler } @@ -1265,6 +1343,24 @@ extension UITableView { public func shouldSpringLoadRowAt(handler: @escaping (_ indexPath: IndexPath, _ context: UISpringLoadedInteractionContext) -> Bool) -> Self { return update { $0.shouldSpringLoadRowAt = handler } } + + + + + @available(iOS 13, *) @discardableResult + public func shouldBeginMultipleSelectionInteraction(handler: @escaping (_ indexPath: IndexPath) -> Bool) -> Self { + return update { $0.shouldBeginMultipleSelectionInteractionAt = handler } + } + + @available(iOS 13, *) @discardableResult + public func didBeginMultipleSelectionInteractionAt(handler: @escaping (_ indexPath: IndexPath) -> Void) -> Self { + return update { $0.didBeginMultipleSelectionInteractionAt = handler } + } + + @available(iOS 13, *) @discardableResult + public func didEndMultipleSelectionInteraction(handler: @escaping () -> Void) -> Self { + return update { $0.didEndMultipleSelectionInteraction = handler } + } } @available(iOS 9.0, *) diff --git a/Xcode/ClosuresTests/UICollectionViewTests.swift b/Xcode/ClosuresTests/UICollectionViewTests.swift index a07f087..2672185 100644 --- a/Xcode/ClosuresTests/UICollectionViewTests.swift +++ b/Xcode/ClosuresTests/UICollectionViewTests.swift @@ -170,9 +170,13 @@ class UICollectionViewTests: XCTestCase { _ = delegate.collectionView!(collectionView, shouldDeselectItemAt: iPath) delegate.collectionView!(collectionView, didSelectItemAt: iPath) delegate.collectionView!(collectionView, didDeselectItemAt: iPath) - _ = delegate.collectionView!(collectionView, shouldShowMenuForItemAt: iPath) - _ = delegate.collectionView!(collectionView, canPerformAction: #selector(UICollectionViewTests.setUp), forItemAt: iPath, withSender: nil) - delegate.collectionView!(collectionView, performAction: #selector(UICollectionViewTests.setUp), forItemAt: iPath, withSender: nil) + if #available(iOS 13, *) { + exp.expectedFulfillmentCount -= 3 + } else { + _ = delegate.collectionView!(collectionView, shouldShowMenuForItemAt: iPath) + _ = delegate.collectionView!(collectionView, canPerformAction: #selector(UICollectionViewTests.setUp), forItemAt: iPath, withSender: nil) + delegate.collectionView!(collectionView, performAction: #selector(UICollectionViewTests.setUp), forItemAt: iPath, withSender: nil) + } _ = delegate.collectionView!(collectionView, transitionLayoutForOldLayout: collectionView.collectionViewLayout, newLayout: collectionView.collectionViewLayout) _ = delegate.collectionView!(collectionView, targetContentOffsetForProposedContentOffset: .zero) _ = delegate.collectionView!(collectionView, targetIndexPathForMoveFromItemAt: iPath, toProposedIndexPath: iPath) diff --git a/Xcode/ClosuresTests/UITableViewTests.swift b/Xcode/ClosuresTests/UITableViewTests.swift index 30c7384..263893a 100644 --- a/Xcode/ClosuresTests/UITableViewTests.swift +++ b/Xcode/ClosuresTests/UITableViewTests.swift @@ -113,9 +113,13 @@ class UITableViewTests: XCTestCase { exp.fulfill() return nil } - tableView.editActionsForRowAt { _ in - exp.fulfill() - return nil + if #available(iOS 13, *) { + exp.expectedFulfillmentCount -= 1 + } else { + tableView.editActionsForRowAt { _ in + exp.fulfill() + return nil + } } tableView.shouldIndentWhileEditingRowAt { _ in exp.fulfill() @@ -135,16 +139,20 @@ class UITableViewTests: XCTestCase { exp.fulfill() return 0 } - tableView.shouldShowMenuForRowAt { _ in - exp.fulfill() - return true - } - tableView.canPerformAction {_,_,_ in - exp.fulfill() - return true - } - tableView.performAction { _,_,_ in - exp.fulfill() + if #available(iOS 13, *) { + exp.expectedFulfillmentCount -= 3 + } else { + tableView.shouldShowMenuForRowAt { _ in + exp.fulfill() + return true + } + tableView.canPerformAction {_,_,_ in + exp.fulfill() + return true + } + tableView.performAction { _,_,_ in + exp.fulfill() + } } tableView.canFocusRowAt { _ in exp.fulfill() @@ -196,6 +204,19 @@ class UITableViewTests: XCTestCase { tableView.moveRowAt { _,_ in exp.fulfill() } + if #available(iOS 13, *) { + exp.expectedFulfillmentCount += 3 + tableView.shouldBeginMultipleSelectionInteraction { (_) -> Bool in + exp.fulfill() + return false + } + tableView.didBeginMultipleSelectionInteractionAt { (_) in + exp.fulfill() + } + tableView.didEndMultipleSelectionInteraction { + exp.fulfill() + } + } XCTAssertNotNil(tableView.delegate) XCTAssertNotNil(tableView.dataSource) @@ -228,15 +249,21 @@ class UITableViewTests: XCTestCase { delegate.tableView!(tableView, didDeselectRowAt: iPath) _ = delegate.tableView!(tableView, editingStyleForRowAt: iPath) _ = delegate.tableView!(tableView, titleForDeleteConfirmationButtonForRowAt: iPath) - _ = delegate.tableView!(tableView, editActionsForRowAt: iPath) + if #available(iOS 13, *) { + } else { + _ = delegate.tableView!(tableView, editActionsForRowAt: iPath) + } _ = delegate.tableView!(tableView, shouldIndentWhileEditingRowAt: iPath) delegate.tableView!(tableView, willBeginEditingRowAt: iPath) delegate.tableView!(tableView, didEndEditingRowAt: iPath) _ = delegate.tableView!(tableView, targetIndexPathForMoveFromRowAt: iPath, toProposedIndexPath: iPath) _ = delegate.tableView!(tableView, indentationLevelForRowAt: iPath) - _ = delegate.tableView!(tableView, shouldShowMenuForRowAt: iPath) - _ = delegate.tableView!(tableView, canPerformAction: #selector(UITableViewTests.setUp), forRowAt: iPath, withSender: nil) - _ = delegate.tableView!(tableView, performAction: #selector(UITableViewTests.setUp), forRowAt: iPath, withSender: nil) + if #available(iOS 13, *) { + } else { + _ = delegate.tableView!(tableView, shouldShowMenuForRowAt: iPath) + _ = delegate.tableView!(tableView, canPerformAction: #selector(UITableViewTests.setUp), forRowAt: iPath, withSender: nil) + _ = delegate.tableView!(tableView, performAction: #selector(UITableViewTests.setUp), forRowAt: iPath, withSender: nil) + } _ = delegate.tableView!(tableView, canFocusRowAt: iPath) _ = delegate.indexPathForPreferredFocusedView!(in: tableView) _ = datasource.tableView(tableView, numberOfRowsInSection: 0) @@ -250,7 +277,12 @@ class UITableViewTests: XCTestCase { _ = datasource.tableView!(tableView, sectionForSectionIndexTitle: "", at: 0) datasource.tableView!(tableView, commit: .delete, forRowAt: iPath) datasource.tableView!(tableView, moveRowAt: iPath, to: iPath) - + if #available(iOS 13, *) { + _ = delegate.tableView!(tableView, shouldBeginMultipleSelectionInteractionAt: iPath) + delegate.tableView!(tableView, didBeginMultipleSelectionInteractionAt: iPath) + delegate.tableViewDidEndMultipleSelectionInteraction!(tableView) + } + waitForExpectations(timeout: 0.2) } @@ -271,7 +303,12 @@ class UITableViewTests: XCTestCase { } func testTableViewMethodExpectations() { - let lastKnownDelegateCount = 41 + let lastKnownDelegateCount: Int + if #available(iOS 13, *) { + lastKnownDelegateCount = 48 + } else { + lastKnownDelegateCount = 41 + } let lastKnownDataSourceCount = 11 let delegateCount = numberOfMethods(in: UITableViewDelegate.self)