Ios4 如何在iOS 4中注册UIApplicationWillTerminateNotification

Ios4 如何在iOS 4中注册UIApplicationWillTerminateNotification,ios4,notifications,Ios4,Notifications,这是一个真正的新手: 使用iOS4。 如何在多个对象中注册UIApplicationWillTerminateNotification 谢谢 在iOS4中,支持后台执行的应用程序通常不会调用applicationWillTerminate。这可能就是你遇到问题的原因 如果已禁用该选项,则可以注册对象以侦听UIApplicationWillTerminateNotification通知,和/或覆盖应用程序委托的-applicationWillTerminate:方法,并将代码放在其中: //set

这是一个真正的新手:

使用iOS4。 如何在多个对象中注册
UIApplicationWillTerminateNotification


谢谢

在iOS4中,支持后台执行的应用程序通常不会调用applicationWillTerminate。这可能就是你遇到问题的原因

如果已禁用该选项,则可以注册对象以侦听UIApplicationWillTerminateNotification通知,和/或覆盖应用程序委托的-applicationWillTerminate:方法,并将代码放在其中:

//set up this class as an observer of UIApplicationWillTerminateNotification
//so we can intervene when the app is about to exit.
[[NSNotificationCenter defaultCenter]
                         addObserver:self
                            selector:@selector(applicationWillTerminate:)
                                name:UIApplicationWillTerminateNotification
                              object:[UIApplication sharedApplication]];