| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ extension Timer { | |||
| 31 | 31 | /// Create and schedule a timer that will call `block` once after the specified time. | |
| 32 | 32 | ||
| 33 | 33 | @discardableResult | |
| 34 | - public class func after(_ interval: TimeInterval, _ block: () -> Void) -> Timer { | ||
| 34 | + public class func after(_ interval: TimeInterval, _ block: @escaping () -> Void) -> Timer { | ||
| 35 | 35 | let timer = Timer.new(after: interval, block) | |
| 36 | 36 | timer.start() | |
| 37 | 37 | return timer | |
@@ -40,7 +40,7 @@ extension Timer { | |||
| 40 | 40 | /// Create and schedule a timer that will call `block` repeatedly in specified time intervals. | |
| 41 | 41 | ||
| 42 | 42 | @discardableResult | |
| 43 | - public class func every(_ interval: TimeInterval, _ block: () -> Void) -> Timer { | ||
| 43 | + public class func every(_ interval: TimeInterval, _ block: @escaping () -> Void) -> Timer { | ||
| 44 | 44 | let timer = Timer.new(every: interval, block) | |
| 45 | 45 | timer.start() | |
| 46 | 46 | return timer | |
@@ -50,7 +50,7 @@ extension Timer { | |||
| 50 | 50 | /// (This variant also passes the timer instance to the block) | |
| 51 | 51 | ||
| 52 | 52 | @nonobjc @discardableResult | |
| 53 | - public class func every(_ interval: TimeInterval, _ block: (Timer) -> Void) -> Timer { | ||
| 53 | + public class func every(_ interval: TimeInterval, _ block: @escaping (Timer) -> Void) -> Timer { | ||
| 54 | 54 | let timer = Timer.new(every: interval, block) | |
| 55 | 55 | timer.start() | |
| 56 | 56 | return timer | |
@@ -64,7 +64,7 @@ extension Timer { | |||
| 64 | 64 | /// Use `NSTimer.after` to create and schedule a timer in one step. | |
| 65 | 65 | /// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947) | |
| 66 | 66 | ||
| 67 | - public class func new(after interval: TimeInterval, _ block: () -> Void) -> Timer { | ||
| 67 | + public class func new(after interval: TimeInterval, _ block: @escaping () -> Void) -> Timer { | ||
| 68 | 68 | return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0) { _ in | |
| 69 | 69 | block() | |
| 70 | 70 | } | |
@@ -76,7 +76,7 @@ extension Timer { | |||
| 76 | 76 | /// Use `NSTimer.every` to create and schedule a timer in one step. | |
| 77 | 77 | /// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947) | |
| 78 | 78 | ||
| 79 | - public class func new(every interval: TimeInterval, _ block: () -> Void) -> Timer { | ||
| 79 | + public class func new(every interval: TimeInterval, _ block: @escaping () -> Void) -> Timer { | ||
| 80 | 80 | return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in | |
| 81 | 81 | block() | |
| 82 | 82 | } | |
@@ -89,7 +89,7 @@ extension Timer { | |||
| 89 | 89 | /// Use `NSTimer.every` to create and schedule a timer in one step. | |
| 90 | 90 | /// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947) | |
| 91 | 91 | ||
| 92 | - @nonobjc public class func new(every interval: TimeInterval, _ block: (Timer) -> Void) -> Timer { | ||
| 92 | + @nonobjc public class func new(every interval: TimeInterval, _ block: @escaping (Timer) -> Void) -> Timer { | ||
| 93 | 93 | var timer: Timer! | |
| 94 | 94 | timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in | |
| 95 | 95 | block(timer) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,7 +74,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { | |||
| 74 | 74 | self.test7() | |
| 75 | 75 | } | |
| 76 | 76 | ||
| 77 | - timer.start(runLoop: .current, modes: .defaultRunLoopMode, RunLoopMode(NSEventTrackingRunLoopMode)) | ||
| 77 | + timer.start(runLoop: .current, modes: .defaultRunLoopMode, .eventTrackingRunLoopMode) | ||
| 78 | 78 | } | |
| 79 | 79 | ||
| 80 | 80 | func test7() { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments