调试时从后台删除应用程序
我正在 iOS 4 及更高版本中调试我的应用程序的一个问题,该问题在关闭时似乎不会保存进度。我正在使用 Xcode 4.0 并在模拟器中运行它,当我在模拟器中关闭应用程序时,将其从后台应用程序栏中删除,然后从模拟器中重新启动它,它似乎在下面的 retval 行中中断
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
:引用“线程 1:程序收到信号:“SIGKILL”,我不太确定该怎么做(而且我刚刚开始使用 Xcode 4)。
有人可以解释一下这里发生了什么吗?我是否可以一旦我将应用程序放在后台(和/或删除它),就不会进行调试,或者这是否可能表明我的保存进度问题?我基本上在我的主要委托收到时触发保存:
- (void)applicationWillTerminate:(UIApplication *)application
I am debugging an issue for my app in iOS 4 and above where it doesn't appear to save progress when it's closed. I'm using Xcode 4.0 and running it in the simulator, and, when I close the app in the simulator, remove it from the background apps bar, then relaunch it from the simulator, it appears to break in the retval line below:
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
It cites "Thread 1: Program received signal: "SIGKILL" and I'm not quite sure what to make of it (also I'm just minutes new to using Xcode 4).
Can someone explain what's going on here, whether I simply can't debug once I stick an app in background (and/or remove it), or whether this potentially points to my issue with saving progress? I basically trigger the save when my main delegate receives:
- (void)applicationWillTerminate:(UIApplication *)application
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该保存在
applicationDidEnterBackground:
中,而不是applicationWillTerminate:
中。当后台应用程序关闭时,它会被终止,而不发送applicationWillTerminate:
(这是您收到的 SIGKILL)。但是,如果您支持没有多任务处理的设备或版本,则还需要在applicationWillTerminate:
中保存,因为它在这些情况下使用。You should save in
applicationDidEnterBackground:
, notapplicationWillTerminate:
. When an app in the background is closed, it is killed without sendingapplicationWillTerminate:
(this is the SIGKILL you are getting). However, if you are supporting devices or versions without multitasking, you will need to save inapplicationWillTerminate:
also, since it is used in those circumstances.