To quit or exit an iOS app in Swift, you can use the exit(0)
function. Here is an example of how to use it:
main.swift217 chars7 lines
This function sends an action to suspend the app's URL session task, waits for 1 second using a DispatchQueue
, then calls the exit(0)
function to terminate the app. Note that calling the exit(0)
function is generally not recommended, as it can be seen as a "force quit" and may lead to a negative user experience. It's better to let the user close the app through the normal iOS UI.
gistlibby LogSnag