https://github.com/remirobert/loop
Handle repetitive loop on iOS easily.
https://github.com/remirobert/loop
Last synced: about 1 month ago
JSON representation
Handle repetitive loop on iOS easily.
- Host: GitHub
- URL: https://github.com/remirobert/loop
- Owner: remirobert
- License: mit
- Created: 2016-04-21T06:03:50.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-21T06:33:42.000Z (about 10 years ago)
- Last Synced: 2025-02-28T17:54:06.609Z (over 1 year ago)
- Language: Swift
- Size: 14.6 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Loop
Handle repetitive action in loop on iOS easily. With a **swifty** syntax.

# Before Loop
Before using **Loop**, you should create a "loop" using **NSTimer** like this :
```swift
override func viewDidLoad() {
super.viewDidLoad()
timer = NSTimer(timeInterval: 3, target: self, selector: #selector(ViewController.loopFunc), userInfo: nil, repeats: true)
timer.fire()
}
func loopFunc() {
NSLog("loop 2")
}
```
You will love the new way to handle that with **Loop** 🎉 :
# How to use
```swift
class ViewController: UIViewController {
var loop: Loop!
override func viewDidLoad() {
super.viewDidLoad()
loop = Loop(every: 5) {
//Do stuff here !
//You are currently in the MainThread
NSLog("loop fired ! 🔥")
}
}
}
```
Pause a loop :
```swift
loop.pause()
```
Resume a loop :
```swift
loop.resume()
```
Stop a loop :
```swift
loop.stop()
```
Start or restart a stoped loop :
```swift
loop.start()
```