Created
May 11, 2018 21:50
-
-
Save Tulakshana/2ee6444fdec33f95a52abd2d348f1c7b to your computer and use it in GitHub Desktop.
Experimental code to exit an iOS app.
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
@IBAction func btnExit0Tapped (sender: UIButton) { | |
exit(0) // Not recommended by Apple https://developer.apple.com/library/content/qa/qa1561/_index.html and app crashes | |
} | |
@IBAction func btnSuspendTapped (sender: UIButton) { | |
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil) // App exits gracefully | |
} | |
@IBAction func btnFatalErrorTapped (sender: UIButton) { | |
fatalError() // App will crash | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment