Created
April 28, 2018 20:01
-
-
Save jasonyunjoonpark/d52cd56847545c9f050b7c4f85f1953e to your computer and use it in GitHub Desktop.
completion handler for a function that takes a parameter
This file contains 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 { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
DispatchQueue.global(qos: .userInteractive).async { | |
//Background thread | |
func countTo(10) //not sure how to wait for this to be finished before updating the button label on main thread | |
DispatchQueue.main.async { | |
//Update Button Label after count is finished | |
} | |
} | |
} | |
func countTo(number: Int) { | |
var counter = 0 | |
while counter < number { | |
counter += 1 | |
print(counter) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment