The cause is that some children's shoes posted a post on the Forum. The original post is as follows:
"In int retval = uiapplicationmain (argc, argv, nil, nil );
When the [pool drain] line is followed by a breakpoint, It is not executed when you press the Home key. Which one knows why?
You can execute a breakpoint in applicationwillterminate"
I did a lot of tests and checked them online. I found that they could not be done at all. Of course, if you have any good solutions, please let me know. Thank you first.
The experiment concluded as follows: (IOS 4 Environment)
1. There is only one way to end with code, and Apple does not recommend that you call the exit () function. There was a method in the uiapplication class before 2.0 that can be called, but now there is no more, and if you force to use the compiling environment before 2.0, Apple will reject you to publish this program to the app store.
2. After you press the Home key, the program is transferred to the background for running.
3. after pressing the Home Key twice in a row, a program list will appear under the iPhone screen. This list is a list of programs that I thought were transferred to the background for running, I am wrong. This is only a list of recently used programs, whether or not this program runs in the background. If you hold down one of the program icons for a while, when these icons begin to shake, a red minus sign will appear in the upper left corner of the icon, press this minus sign, the program will be cleared from the recently run list. If the program is still running in the background, the program will end.
4. added an option in info. plist. "Application does not run in background". If you have added and selected this item, after you press the Home key, the program will not be transferred to the background for running and will be killed directly.
5. No matter which method is used to kill the program, applicationwillterminate will be called.
This is the result of my experiment. I hope it will be useful to you. If my results are incorrect or there are better methods, please do not give me any further advice. Thank you!