I have just discovered the nifty unhandled exception handler for cocoa-touch.
我刚刚发现了cocoa-touch的漂亮的未处理异常处理程序。
Now that I can gracefully notify the user about any unhandled exceptions that might crash my application, I'd like to shut down my application after notifying the user that a crash has occured.
现在我可以优雅地通知用户任何可能导致我的应用程序崩溃的未处理异常,我想在通知用户发生崩溃后关闭我的应用程序。
Does anyone know how to shut down an application programmatically?
有谁知道如何以编程方式关闭应用程序?
3 个解决方案
#1
6
You can call [[UIApplication sharedApplication] terminate]; - that won't build the screenshot Springboard uses to animate the application's exit, though, so the screen will just go black until the icons move in. There doesn't seem to be a published way to do this; the UIApplication header doesn't even mention the -terminate method, so you may just not be meant to do it at all.
你可以调用[[UIApplication sharedApplication] terminate]; - 这不会构建Springboard用于动画应用程序退出的屏幕截图,因此屏幕将变黑,直到图标移入。似乎没有公布的方法来执行此操作; UIApplication标题甚至没有提到-terminate方法,所以你根本不应该这样做。
#2
2
exit(0);
will do the trick...
会做的伎俩......
#3
0
Apple's documentation says there is no "normal" way to shut down. In your case - an unhandled exception - immediate termination makes sense anyway.
Apple的文档说没有“正常”的关闭方式。在你的情况下 - 一个未处理的例外 - 无论如何立即终止是有道理的。
#1
6
You can call [[UIApplication sharedApplication] terminate]; - that won't build the screenshot Springboard uses to animate the application's exit, though, so the screen will just go black until the icons move in. There doesn't seem to be a published way to do this; the UIApplication header doesn't even mention the -terminate method, so you may just not be meant to do it at all.
你可以调用[[UIApplication sharedApplication] terminate]; - 这不会构建Springboard用于动画应用程序退出的屏幕截图,因此屏幕将变黑,直到图标移入。似乎没有公布的方法来执行此操作; UIApplication标题甚至没有提到-terminate方法,所以你根本不应该这样做。
#2
2
exit(0);
will do the trick...
会做的伎俩......
#3
0
Apple's documentation says there is no "normal" way to shut down. In your case - an unhandled exception - immediate termination makes sense anyway.
Apple的文档说没有“正常”的关闭方式。在你的情况下 - 一个未处理的例外 - 无论如何立即终止是有道理的。