运行 Simulator 4.0 的 iPhone 应用程序收到 Sigkill
我刚刚获得 iPhone SDK 4,我试图停止开发我之前正在开发的应用程序。所以我同时实现了 -(void)applicationDidEnterBackground:(UIApplication *)application
和 - (void)applicationWillTerminate:(UIApplication *)application
当我单击模拟器 4.0 中的主页按钮时,它似乎工作正常。该应用程序调用 -(void)applicationDidEnterBackground:(UIApplication *)application
并进入后台状态。
但是,我然后双击主页按钮以公开在后台运行的应用程序,并按住它显示减号或退出。当我单击减号时,调试器会说
程序收到信号:“SIGKILL”
此外,- (void)applicationWillTerminate:(UIApplication *)application
永远不会被调用。我是否缺少一些需要做的事情才能在 OS4 上运行?或者至少有人可以指出我调试 SIGKILL 的方法。谢谢。
I just got the iPhone SDK 4 and I'm trying to leave off developing an app I was working on before. So I implemented both-(void)applicationDidEnterBackground:(UIApplication *)application
and - (void)applicationWillTerminate:(UIApplication *)application
When I click the home button in the simulator 4.0, it seems to work okay. The app calls -(void)applicationDidEnterBackground:(UIApplication *)application
and enters the background state..
However, I then double click the home button to expose the app running in the background, and hold it down to show the minus sign in or to exit. When I click the minus sign, the debugger says
Program received signal: "SIGKILL"
in addition, - (void)applicationWillTerminate:(UIApplication *)application
is never called. Am I missing something I need to do for this to work on OS4? Or at least can somebody point me to a way to debug SIGKILL. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
-applicationWillTerminate:
仅当您的应用程序在被要求退出时处于运行状态时才会被调用。如果它已经处于挂起状态(正如您在此处所看到的那样),系统只需向应用程序发送一个终止信号。当用户按下红色减号按钮手动终止应用程序以及系统决定放弃应用程序以释放前台应用程序的内存时,就会发生这种情况。如果您的应用程序在后台运行(例如,播放音乐或运行某些后台任务)并且用户通过按减号按钮手动终止应用程序,只有这样您才会真正获得
-applicationWillTerminate:
信息。因此,您必须保存所有状态/等。在从-applicationDidEnterBackground:
返回之前。-applicationWillTerminate:
is only called if your application is in a running state when it is asked to quit. If it is already in a suspended state (as you have it here), the system simply sends a kill signal to the application. This happens when the user presses the red minus buttons to terminate the app manually as well as when the system decides to jettison the app to free up memory for the foreground application.If you application is running in the background (playing music or running some background tasks, for instance) and the user manually terminates the application by pressing the minus button, only then will you actually get an
-applicationWillTerminate:
message. Therefore, you must save all your state/etc. before you return from-applicationDidEnterBackground:
.这是可以预料的,多任务栏“红色关闭按钮”相当于在 Mac OS X 上强制退出应用程序。这是记录的行为。 Apple 希望 iOS 4 的普通用户能够简单地启动/使用/关闭应用程序,而无需考虑终止进程或其他任何事情。系统会对此进行管理。
只需确保将所有重要数据保存在 application:willResignActive: 或 applicationWillEnterBackground 中。因为此后,当内存压力迫使系统清理时,您可能会被杀死... Snow Leopard 为在其 Info.plist 中使用 NSSupportsSuddenTermination 键的应用程序引入了类似的行为。应用程序基本上告诉系统它会定期一点一点地保存数据,这样当它进入后台时就没有什么可做的或很少了。与大型整体应用程序桌面应用程序不同...
This is to be expected the multitasking bar "red close button" is the equivalent of force quitting an application on Mac OS X. This is the documented behavior. Apple expects normal users of iOS 4 to simply launch / use / dimiss apps they don't have to think in terms of terminating processes or anything. The system will manage that.
Just make sure to save any important data in application:willResignActive: or applicationWillEnterBackground. Because after that you might get killed when memory pressure forces the system to clean up... Snow Leopard introduced a similar behavior for apps that use the NSSupportsSuddenTermination key in their Info.plist. An app basically tells the system that it periodically saves its data bit by bit, so that when it goes in background there's nothing left to do or very little. Unlike big monolithic apps desktop apps...