From 93bdf22132c759842d99a2caa26d2c0ae1825b52 Mon Sep 17 00:00:00 2001 From: Amr Abdel-Wahab Date: Tue, 29 Dec 2020 15:31:28 +0200 Subject: [PATCH] Swift5 Migration --- CountdownLabel.xcodeproj/project.pbxproj | 5 +++-- CountdownLabel/CountdownLabel.swift | 2 +- CountdownLabel/LTMorphingLabel/LTEasing.swift | 4 ++-- CountdownLabelTests/CountdownLabelTests.swift | 13 +++++-------- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CountdownLabel.xcodeproj/project.pbxproj b/CountdownLabel.xcodeproj/project.pbxproj index 38c9849..ba69951 100644 --- a/CountdownLabel.xcodeproj/project.pbxproj +++ b/CountdownLabel.xcodeproj/project.pbxproj @@ -233,6 +233,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 892106C61C3CF4140007CDEC; @@ -449,7 +450,7 @@ PRODUCT_NAME = CountdownLabel; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -474,7 +475,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.keishi.suzuki.CountdownLabel; PRODUCT_NAME = CountdownLabel; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/CountdownLabel/CountdownLabel.swift b/CountdownLabel/CountdownLabel.swift index 7314dab..da20eb4 100644 --- a/CountdownLabel/CountdownLabel.swift +++ b/CountdownLabel/CountdownLabel.swift @@ -33,7 +33,7 @@ public class CountdownLabel: LTMorphingLabel { public var dateFormatter: DateFormatter { let df = DateFormatter() df.locale = Locale(identifier: "en_US_POSIX") - df.timeZone = NSTimeZone(name: "GMT") as TimeZone! + df.timeZone = TimeZone(identifier:"GMT") df.dateFormat = timeFormat return df } diff --git a/CountdownLabel/LTMorphingLabel/LTEasing.swift b/CountdownLabel/LTMorphingLabel/LTEasing.swift index 090d37d..62ed49f 100644 --- a/CountdownLabel/LTMorphingLabel/LTEasing.swift +++ b/CountdownLabel/LTMorphingLabel/LTEasing.swift @@ -18,13 +18,13 @@ public struct LTEasing { public static func easeOutQuint(_ t: Float, _ b: Float, _ c: Float, _ d: Float = 1.0) -> Float { return { - return c * ($0 * $0 * $0 * $0 * $0 + 1.0) + b + return c * (pow($0, 5) + 1.0) + b }(t / d - 1.0) } public static func easeInQuint(_ t: Float, _ b: Float, _ c: Float, _ d: Float = 1.0) -> Float { return { - return c * $0 * $0 * $0 * $0 * $0 + b + return (c * pow($0, 5) + b) }(t / d) } diff --git a/CountdownLabelTests/CountdownLabelTests.swift b/CountdownLabelTests/CountdownLabelTests.swift index 5e10cf1..e94aae5 100644 --- a/CountdownLabelTests/CountdownLabelTests.swift +++ b/CountdownLabelTests/CountdownLabelTests.swift @@ -279,7 +279,7 @@ class CountdownLabelExampleTests: XCTestCase { label.setCountDownTime(minutes: 10) label.countdownAttributedText = CountdownAttributedText(text: "HELLO TIME IS HERE NOW", replacement: "HERE", - attributes: [NSForegroundColorAttributeName: UIColor.redColor()]) + attributes: [NSAttributedString.Key.foregroundColor: UIColor.red]) label.start() XCTAssertEqual(label.attributedText!.string, "HELLO TIME IS 00:00:10 NOW") @@ -292,7 +292,7 @@ class CountdownLabelExampleTests: XCTestCase { label.countdownAttributedText = CountdownAttributedText(text: "HELLO TIME IS HERE NOW", replacement: "HERE", - attributes: [NSForegroundColorAttributeName: UIColor.redColor()]) + attributes: [NSAttributedString.Key.foregroundColor: UIColor.red]) label.start() @@ -360,11 +360,8 @@ class CountdownLabelExampleTests: XCTestCase { } func delay(delay: Double, closure: ()->()) { - dispatch_after( - dispatch_time( - dispatch_time_t(DISPATCH_TIME_NOW), - Int64(delay * Double(NSEC_PER_SEC)) - ), - dispatch_get_main_queue(), closure) + DispatchQueue.main.asyncAfter(deadline: .now() + delay , execute: { + closure() + }) } }