Why does closing the simulator make my app receive SIGTERM when my app is in the background?
When I get this:
- (void)applicationWillResignActive:(UIApplication *)application {
I release all my objects and invalidate all my timers.
When I get this:
- (void)applicationDidBecomeActive:(UIApplication *)application {
I reallocate all my objects and get my timers running again.
It all works fine except that now if I put my program into the background, then I actually terminate the program by closing the IOS Simulator, it gives a SIGTERM signal at line:
int retVal = UIApplicationMain(argc, argv, nil, nil);
On the other hand if开发者_高级运维 I terminate the program by closing the IOS Simulator without putting it into the background first it does not give the SIGTERM signal.
Am I doing something wrong?
For me the leading cause of these kinds of SIGTERMs has been the following. If I release any object that I never owned or already released just prior to terminating the program, then I get that SIGTERM when I terminate the program.
I do not know how to get info from the simulator or debugger about which object I have done this to. But knowing from the SIGTERM that I have done an extraneous release has been enough for me to hunt it down by inspection.
If anyone knows how to look-up which object has been released extraneously in xcode please chime in.
You're not doing anything wrong. When you close the iOS Simulator, it kills your app by sending it SIGTERM
. Period. That's just the way it works. If you leave your app in the foreground, it'll still be killed, just not by a SIGTERM
. Your app is still connected to the simulator when it's in the background; it cannot continue existing without the simulator and it has no way to connect to another instance of the simulator should you start one.
If you don't want your app to receive SIGTERM
, don't close the simulator.
精彩评论