Is it ok to use exit(0) in "applicationDidEnterBackground:(UIApplication *)application"?
My app crash on exit after upgrade to sdk 4, the error is bad memory access.
I figured that if I put "exit(0)" in "applicationDidEnterBackground:(UIApplication *)application", the app would exit normally.
However, is this ok? This is my only "solution" to the problem so far.
NSZ开发者_如何转开发ombie is not too helpful this time...
If there's a bad memory access issue, I think the best solution should be to find and fix the memory issue.
However, if you want to stick to the "prevent entering background" way, you should use the appropriate method : disable multitasking. It is described here.
If you do not want your application to remain in the background when it is quit, you can explicitly opt out of the background execution model by adding the UIApplicationExitsOnSuspend key to your application’s Info.plist file and setting its value to YES
Do not put exit(0) in applicationDidEnterBackground:(UIApplication *)application.
Instead, add a key to your Info.plist file to flag that you want the application to exit when it is suspended. For details look at Property List Options.
I find the source of the problem. The problem is that I need to perform all task that affect the interface or views on the main thread. Figuring out this also solved a multiply other bugs that give me headcase. It seems that iOS 4 is more restrictive on thread usage
精彩评论