Skip to content

Instantly share code, notes, and snippets.

@jasonyunjoonpark
Created April 29, 2018 18:47
Show Gist options
  • Save jasonyunjoonpark/35ca012883bdecde5544c60f5d9d2a41 to your computer and use it in GitHub Desktop.
Save jasonyunjoonpark/35ca012883bdecde5544c60f5d9d2a41 to your computer and use it in GitHub Desktop.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var counterLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
DispatchQueue.global(qos: .userInteractive).async {
let result = self.countTo(number: 1000)
DispatchQueue.main.async {
self.counterLabel.text = "\(result)"
}
}
}
func countTo(number: Int) -> Int {
var counter = 0
while counter < number {
counter += 1
print(counter)
}
return counter
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment