سؤال

I've created a Mac OS X application, and during the development it was fine because I opened it with Xcode.

But now, I try to execute the executable and it's working only the first time, because after close the window, the app persists in memory. And I have to kill it with the activity monitor.

So what should I do to kill the app when I touch the red top left button on the window?

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

Override the windowWillClose method in your delegate to make it terminate the app.

- (void)windowWillClose:(NSNotification *)aNotification {
    [NSApp terminate:self];
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top