applicationWillTerminate not called

江枫思渺然 提交于 2019-12-11 00:44:46

问题


I implemented applicationWillTerminate method, but it's never called

-(void)applicationWillTerminate:(NSNotification *)notification
{
    [[NSApplication sharedApplication] terminate:self];
    NSLog(@"EOP");
}

How to execute some code before application close?

Thanks


回答1:


I just added

-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *) sender{
return YES;
}

Now applicationWillTerminate invokes




回答2:


please set a key (UIApplicationExitsOnSuspend) in your plist to YES.

Key : UIApplicationExitsOnSuspend
Type : Boolean
Value :YES



来源:https://stackoverflow.com/questions/8193305/applicationwillterminate-not-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!