Created
January 15, 2017 12:53
-
-
Save owenzhao/ecdd1e4c35357ccdfe8050ea6c2e044d to your computer and use it in GitHub Desktop.
polling
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
@IBAction func printHello(_ sender: Any) { | |
// 忙等待 | |
DispatchQueue(label: "default").async { | |
while true { | |
if self.shouldWaitSwitch.isOn { continue } | |
print("你好!") | |
break | |
} | |
} | |
} | |
@IBOutlet weak var shouldWaitSwitch: UISwitch! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment