1

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.

NSZombie is not too helpful this time...

Mak Sing
  • 871
  • 2
  • 9
  • 18

3 Answers3

5

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

David
  • 998
  • 7
  • 17
  • David is right, you should not do that. Apple Human Interface Guidelines will tell you that's wrong. – Pierre Valade Jul 27 '10 at 09:39
  • Agreed. Don't treat the symptom, but find the source of the problem. – Brad Larson Jul 27 '10 at 12:17
  • 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 – Mak Sing Jul 29 '10 at 03:36
1

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.

xmr
  • 635
  • 8
  • 9
  • It is werid, I tried add the property but it doesn't seem to do anything... The function applicationDidEnterBackground is still being called and I still get the error.. maybe I missed something. – Mak Sing Jul 27 '10 at 14:16
0

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

Mak Sing
  • 871
  • 2
  • 9
  • 18