Created
April 29, 2018 18:47
-
-
Save jasonyunjoonpark/35ca012883bdecde5544c60f5d9d2a41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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