可以在“applicationDidEnterBackground:(UIApplication *)application”中使用exit(0)吗? [英] Is it ok to use exit(0) in "applicationDidEnterBackground:(UIApplication *)application"?

查看:176
本文介绍了可以在“applicationDidEnterBackground:(UIApplication *)application”中使用exit(0)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到sdk 4后,我的应用程序在退出时崩溃,错误是内存访问不良。

My app crash on exit after upgrade to sdk 4, the error is bad memory access.

我想如果我把exit(0)放入 applicationDidEnterBackground :( UIApplication *)application,应用程序将正常退出。

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不太有帮助......

NSZombie 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.


如果您不希望自己的应用程序保留在后台退出,您可以通过将UIApplicationExitsOnSuspend键添加到应用程序的Info.plist文件并将其值设置为YES

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

这篇关于可以在“applicationDidEnterBackground:(UIApplication *)application”中使用exit(0)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆