1
I’m developing an example app for Iphone using Xcode with Swift 3.0. I need to put a button that when clicked closes the entire application. I couldn’t identify any event or function that does this.
1
I’m developing an example app for Iphone using Xcode with Swift 3.0. I need to put a button that when clicked closes the entire application. I couldn’t identify any event or function that does this.
0
There is a method to "exit" the application:
exit(0)
UPDATE
Quoting the reply of Jeff Wolski (translated into English):
According to Apple’s Human User Guidelines...
Do not close the application by code
Never terminate an iOS app by code, as your users tend to to interpret this as a crash. However, if any circumstances external prevents your application from working as it should, you should inform the user about this situation and explain what he can do so. [...]
In C
, exit(0)
will interrupt the execution of the application suddenly ("0" is the earl status which says the closure has successfully occurred). It means that no method of delegate or exception algorithm will be called. So if your goal is to make sure some code is called before you close the application, even if it’s forced, maybe there’s a better way to do that. In his AppDelegate
, implement a customized method such as: -(void)applicaitonIsgoingAway
. Call this method within where you want to terminate the application:
applicationWillTerminate
applicaitonDidEnterBackground
onUncaughtException
Browser other questions tagged html swift-3
You are not signed in. Login or sign up in order to post.
Do you have any official documentation on this method? If yes, it would be nice to put the link of the same in the answer to serve reference and study material.
– Woss
I used an answer in English to support the answer here.
– Rici