Skip to content

Commit 109e2fc

Browse files
committed
Make start use variadic argument for modes instead of array
1 parent 80e75b2 commit 109e2fc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Src/SwiftyTimer.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ extension NSTimer {
8080
/// By default, the timer is scheduled on the current run loop for the default mode.
8181
/// Specify `runLoop` or `modes` to override these defaults.
8282

83-
public func start(runLoop: NSRunLoop = NSRunLoop.currentRunLoop(), modes: [String] = [NSDefaultRunLoopMode]) {
83+
public func start(runLoop: NSRunLoop = NSRunLoop.currentRunLoop(), modes: String...) {
84+
let modes = modes.count != 0 ? modes : [NSDefaultRunLoopMode]
85+
8486
for mode in modes {
8587
runLoop.addTimer(self, forMode: mode)
8688
}

Tests/SwiftyTimerTests/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
6262
fired = true
6363
}
6464
}
65-
timer4.start()
65+
timer4.start(runLoop: NSRunLoop.currentRunLoop(), modes: NSDefaultRunLoopMode)
6666
}
6767

6868
func test6() {

0 commit comments

Comments
 (0)