I have some code in my AppDelegate
’s applicationWillTerminate:
method but I don’t know how to test if it works. Using Xcode to stop the simulator does not trigger it.
How do I test the code in applicationWillTerminate:?
Please note that this is specific to the simulator and not the device.
First press Shift+Command+ H twice. This will open up all the apps that are currently open. Swipe left/right to the app you actually want to close. Just Swipe Up using the Touchpad while Holding the App would close the app.
If it seems stuck on this prompt, you can open the iOS simulator manually ( open -a Simulator ) and then in the macOS toolbar, choose Hardware → Device, and select an iOS version and device that you'd like to open. You can also use this menu to open any version of the simulator that you like.
The simulator doesn't send applicationWillTerminate:
because the springboard isn't sending you the kill code (SIGABRT), LLDB is. To trigger those delegate methods, you have to use the Home Button command (⌘+⇧+H), then pull up the multitasking drawer and kill your application from there. Your debugging session will immediately terminate, and the delegate method will fire successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With