Skip to content

Commit 24fd695

Browse files
committed
Merge branch 'swift-3.0' of https://github.com/ldiqual/SwiftyTimer into ldiqual-swift-3.0
2 parents 13777bb + d8409c1 commit 24fd695

File tree

10 files changed

+69
-60
lines changed

10 files changed

+69
-60
lines changed

Sources/SwiftyTimer.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@
2424

2525
import Foundation
2626

27-
extension NSTimer {
27+
extension Timer {
2828

2929
// MARK: Schedule timers
3030

3131
/// Create and schedule a timer that will call `block` once after the specified time.
3232

33-
public class func after(interval: NSTimeInterval, _ block: () -> Void) -> NSTimer {
34-
let timer = NSTimer.new(after: interval, block)
33+
public class func after(_ interval: TimeInterval, _ block: () -> Void) -> Timer {
34+
let timer = Timer.new(after: interval, block)
3535
timer.start()
3636
return timer
3737
}
3838

3939
/// Create and schedule a timer that will call `block` repeatedly in specified time intervals.
4040

41-
public class func every(interval: NSTimeInterval, _ block: () -> Void) -> NSTimer {
42-
let timer = NSTimer.new(every: interval, block)
41+
public class func every(_ interval: TimeInterval, _ block: () -> Void) -> Timer {
42+
let timer = Timer.new(every: interval, block)
4343
timer.start()
4444
return timer
4545
}
4646

4747
/// Create and schedule a timer that will call `block` repeatedly in specified time intervals.
4848
/// (This variant also passes the timer instance to the block)
4949

50-
@nonobjc public class func every(interval: NSTimeInterval, _ block: NSTimer -> Void) -> NSTimer {
51-
let timer = NSTimer.new(every: interval, block)
50+
@nonobjc public class func every(_ interval: TimeInterval, _ block: (Timer) -> Void) -> Timer {
51+
let timer = Timer.new(every: interval, block)
5252
timer.start()
5353
return timer
5454
}
@@ -61,7 +61,7 @@ extension NSTimer {
6161
/// Use `NSTimer.after` to create and schedule a timer in one step.
6262
/// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947)
6363

64-
public class func new(after interval: NSTimeInterval, _ block: () -> Void) -> NSTimer {
64+
public class func new(after interval: TimeInterval, _ block: () -> Void) -> Timer {
6565
return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0) { _ in
6666
block()
6767
}
@@ -73,7 +73,7 @@ extension NSTimer {
7373
/// Use `NSTimer.every` to create and schedule a timer in one step.
7474
/// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947)
7575

76-
public class func new(every interval: NSTimeInterval, _ block: () -> Void) -> NSTimer {
76+
public class func new(every interval: TimeInterval, _ block: () -> Void) -> Timer {
7777
return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in
7878
block()
7979
}
@@ -86,8 +86,8 @@ extension NSTimer {
8686
/// Use `NSTimer.every` to create and schedule a timer in one step.
8787
/// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947)
8888

89-
@nonobjc public class func new(every interval: NSTimeInterval, _ block: NSTimer -> Void) -> NSTimer {
90-
var timer: NSTimer!
89+
@nonobjc public class func new(every interval: TimeInterval, _ block: (Timer) -> Void) -> Timer {
90+
var timer: Timer!
9191
timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in
9292
block(timer)
9393
}
@@ -101,31 +101,31 @@ extension NSTimer {
101101
/// By default, the timer is scheduled on the current run loop for the default mode.
102102
/// Specify `runLoop` or `modes` to override these defaults.
103103

104-
public func start(runLoop runLoop: NSRunLoop = NSRunLoop.currentRunLoop(), modes: String...) {
105-
let modes = modes.isEmpty ? [NSDefaultRunLoopMode] : modes
104+
public func start(runLoop: RunLoop = RunLoop.current, modes: RunLoopMode...) {
105+
let modes = modes.isEmpty ? [RunLoopMode.defaultRunLoopMode] : modes
106106

107107
for mode in modes {
108-
runLoop.addTimer(self, forMode: mode)
108+
runLoop.add(self, forMode: mode)
109109
}
110110
}
111111
}
112112

113113
// MARK: - Time extensions
114114

115115
extension Double {
116-
public var millisecond: NSTimeInterval { return self / 1000 }
117-
public var milliseconds: NSTimeInterval { return self / 1000 }
118-
public var ms: NSTimeInterval { return self / 1000 }
116+
public var millisecond: TimeInterval { return self / 1000 }
117+
public var milliseconds: TimeInterval { return self / 1000 }
118+
public var ms: TimeInterval { return self / 1000 }
119119

120-
public var second: NSTimeInterval { return self }
121-
public var seconds: NSTimeInterval { return self }
120+
public var second: TimeInterval { return self }
121+
public var seconds: TimeInterval { return self }
122122

123-
public var minute: NSTimeInterval { return self * 60 }
124-
public var minutes: NSTimeInterval { return self * 60 }
123+
public var minute: TimeInterval { return self * 60 }
124+
public var minutes: TimeInterval { return self * 60 }
125125

126-
public var hour: NSTimeInterval { return self * 3600 }
127-
public var hours: NSTimeInterval { return self * 3600 }
126+
public var hour: TimeInterval { return self * 3600 }
127+
public var hours: TimeInterval { return self * 3600 }
128128

129-
public var day: NSTimeInterval { return self * 3600 * 24 }
130-
public var days: NSTimeInterval { return self * 3600 * 24 }
129+
public var day: TimeInterval { return self * 3600 * 24 }
130+
public var days: TimeInterval { return self * 3600 * 24 }
131131
}

SwiftyTimer.xcodeproj/project.pbxproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,12 @@
205205
3E721AB21BF7255C008AF027 /* Project object */ = {
206206
isa = PBXProject;
207207
attributes = {
208-
LastUpgradeCheck = 0710;
208+
LastUpgradeCheck = 0800;
209209
ORGANIZATIONNAME = "Radosław Pietruszewski";
210210
TargetAttributes = {
211211
3E721ABA1BF7255D008AF027 = {
212212
CreatedOnToolsVersion = 7.1;
213+
LastSwiftMigration = 0800;
213214
};
214215
6E7E40891C84B1A20030CEBB = {
215216
CreatedOnToolsVersion = 7.2;
@@ -417,6 +418,7 @@
417418
PRODUCT_NAME = "$(TARGET_NAME)";
418419
SKIP_INSTALL = YES;
419420
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
421+
SWIFT_VERSION = 3.0;
420422
};
421423
name = Debug;
422424
};
@@ -436,6 +438,8 @@
436438
PRODUCT_BUNDLE_IDENTIFIER = io.radex.SwiftyTimer;
437439
PRODUCT_NAME = "$(TARGET_NAME)";
438440
SKIP_INSTALL = YES;
441+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
442+
SWIFT_VERSION = 3.0;
439443
};
440444
name = Release;
441445
};
@@ -480,6 +484,7 @@
480484
PRODUCT_NAME = SwiftyTimer;
481485
SDKROOT = macosx;
482486
SKIP_INSTALL = YES;
487+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
483488
};
484489
name = Release;
485490
};
@@ -518,6 +523,7 @@
518523
PRODUCT_NAME = SwiftyTimer;
519524
SDKROOT = appletvos;
520525
SKIP_INSTALL = YES;
526+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
521527
TARGETED_DEVICE_FAMILY = 3;
522528
TVOS_DEPLOYMENT_TARGET = 9.0;
523529
};
@@ -558,6 +564,7 @@
558564
PRODUCT_NAME = SwiftyTimer;
559565
SDKROOT = watchos;
560566
SKIP_INSTALL = YES;
567+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
561568
TARGETED_DEVICE_FAMILY = 4;
562569
WATCHOS_DEPLOYMENT_TARGET = 2.0;
563570
};

SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer OS X.xcscheme

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -11,8 +11,7 @@
1111
buildForRunning = "YES"
1212
buildForProfiling = "YES"
1313
buildForArchiving = "YES"
14-
buildForAnalyzing = "YES"
15-
hideIssues = "NO">
14+
buildForAnalyzing = "YES">
1615
<BuildableReference
1716
BuildableIdentifier = "primary"
1817
BlueprintIdentifier = "6E7E40891C84B1A20030CEBB"

SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer tvOS.xcscheme

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -11,8 +11,7 @@
1111
buildForRunning = "YES"
1212
buildForProfiling = "YES"
1313
buildForArchiving = "YES"
14-
buildForAnalyzing = "YES"
15-
hideIssues = "NO">
14+
buildForAnalyzing = "YES">
1615
<BuildableReference
1716
BuildableIdentifier = "primary"
1817
BlueprintIdentifier = "6E7E40991C84B3790030CEBB"

SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer watchOS.xcscheme

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -11,8 +11,7 @@
1111
buildForRunning = "YES"
1212
buildForProfiling = "YES"
1313
buildForArchiving = "YES"
14-
buildForAnalyzing = "YES"
15-
hideIssues = "NO">
14+
buildForAnalyzing = "YES">
1615
<BuildableReference
1716
BuildableIdentifier = "primary"
1817
BlueprintIdentifier = "6E7E40A71C84B4240030CEBB"

SwiftyTimer.xcodeproj/xcshareddata/xcschemes/SwiftyTimer.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0710"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@
9090
isa = PBXProject;
9191
attributes = {
9292
LastSwiftUpdateCheck = 0700;
93-
LastUpgradeCheck = 0640;
93+
LastUpgradeCheck = 0800;
9494
TargetAttributes = {
9595
6EE9C1521B00BB5B00D6B91C = {
9696
CreatedOnToolsVersion = 6.4;
97+
LastSwiftMigration = 0800;
9798
};
9899
};
99100
};
@@ -159,6 +160,7 @@
159160
COPY_PHASE_STRIP = NO;
160161
DEBUG_INFORMATION_FORMAT = dwarf;
161162
ENABLE_STRICT_OBJC_MSGSEND = YES;
163+
ENABLE_TESTABILITY = YES;
162164
GCC_C_LANGUAGE_STANDARD = gnu99;
163165
GCC_DYNAMIC_NO_PIC = NO;
164166
GCC_NO_COMMON_BLOCKS = YES;
@@ -225,7 +227,9 @@
225227
COMBINE_HIDPI_IMAGES = YES;
226228
INFOPLIST_FILE = SwiftyTimerTests/Info.plist;
227229
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
230+
PRODUCT_BUNDLE_IDENTIFIER = "radex.$(PRODUCT_NAME:rfc1034identifier)";
228231
PRODUCT_NAME = "$(TARGET_NAME)";
232+
SWIFT_VERSION = 3.0;
229233
};
230234
name = Debug;
231235
};
@@ -236,7 +240,10 @@
236240
COMBINE_HIDPI_IMAGES = YES;
237241
INFOPLIST_FILE = SwiftyTimerTests/Info.plist;
238242
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
243+
PRODUCT_BUNDLE_IDENTIFIER = "radex.$(PRODUCT_NAME:rfc1034identifier)";
239244
PRODUCT_NAME = "$(TARGET_NAME)";
245+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
246+
SWIFT_VERSION = 3.0;
240247
};
241248
name = Release;
242249
};

SwiftyTimerTests/SwiftyTimerTests.xcodeproj/xcshareddata/xcschemes/SwiftyTimerTests.xcscheme

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0640"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -11,8 +11,7 @@
1111
buildForRunning = "YES"
1212
buildForProfiling = "YES"
1313
buildForArchiving = "YES"
14-
buildForAnalyzing = "YES"
15-
hideIssues = "NO">
14+
buildForAnalyzing = "YES">
1615
<BuildableReference
1716
BuildableIdentifier = "primary"
1817
BlueprintIdentifier = "6EE9C1521B00BB5B00D6B91C"
@@ -26,8 +25,7 @@
2625
buildForRunning = "YES"
2726
buildForProfiling = "NO"
2827
buildForArchiving = "NO"
29-
buildForAnalyzing = "YES"
30-
hideIssues = "NO">
28+
buildForAnalyzing = "YES">
3129
<BuildableReference
3230
BuildableIdentifier = "primary"
3331
BlueprintIdentifier = "6EE9C1621B00BB5B00D6B91C"

SwiftyTimerTests/SwiftyTimerTests/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<key>CFBundleIconFile</key>
1010
<string></string>
1111
<key>CFBundleIdentifier</key>
12-
<string>radex.$(PRODUCT_NAME:rfc1034identifier)</string>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1313
<key>CFBundleInfoDictionaryVersion</key>
1414
<string>6.0</string>
1515
<key>CFBundleName</key>

0 commit comments

Comments
 (0)