Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift5 Migration #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CountdownLabel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 892106C61C3CF4140007CDEC;
Expand Down Expand Up @@ -449,7 +450,7 @@
PRODUCT_NAME = CountdownLabel;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion CountdownLabel/CountdownLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions CountdownLabel/LTMorphingLabel/LTEasing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
13 changes: 5 additions & 8 deletions CountdownLabelTests/CountdownLabelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()


Expand Down Expand Up @@ -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()
})
}
}