Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn’t stopping an application in iOS simulator trigger applicationWillTerminate:?

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.

like image 553
duci9y Avatar asked Dec 29 '12 07:12

duci9y


People also ask

How to terminate app in iOS simulator?

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.

How do I open the iOS simulator menu?

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.


1 Answers

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.

like image 71
CodaFi Avatar answered Sep 28 '22 21:09

CodaFi