We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b5009e9 commit 4de0130Copy full SHA for 4de0130
1 file changed
README.md
@@ -62,6 +62,20 @@ timer.start()
62
timer.start(modes: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode)
63
```
64
65
+### Invalidation
66
+
67
+If you want to invalidate a repeating timer on some condition, you can take an `NSTimer` argument in the closure you pass in:
68
69
+```swift
70
+NSTimer.every(5.seconds) { (timer: NSTimer) in
71
+ // do something
72
73
+ if finished {
74
+ timer.invalidate()
75
+ }
76
+}
77
+```
78
79
## Installation
80
81
If you're using CocoaPods, just add this line to your Podfile:
0 commit comments