Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to make an application close when window is closed?

In a cocoa application, I read you are to add :


applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app {

return YES;

}


to your apps delegate. Where exaclty do I put it in the delegate because I'm getting errors.

MacBook Pro, OS X Mountain Lion (10.8.2), 2.3 GHz i5, 4GB RAM, OCZ 120GB SSD

Posted on Feb 3, 2013 7:58 PM

Reply
Question marked as Best reply

Posted on Feb 3, 2013 9:02 PM

Application delegate methods are placed in the implementation part of whatever file the application is using for the delegate, for example AppDelegate.m. From your other topics, I'm thinking you are talking about an AppleScriptObjC project, though - in that case, the various Cocoa methods need to be converted (see the AppleScriptObjC Release Notes), and delegate methods are placed in the main script object in the AppDelegate.applescript file:


on applicationShouldTerminateAfterLastWindowClosed_(sender)

returntrue

end applicationShouldTerminateAfterLastWindowClosed_

1 reply
Question marked as Best reply

Feb 3, 2013 9:02 PM in response to MacMan240

Application delegate methods are placed in the implementation part of whatever file the application is using for the delegate, for example AppDelegate.m. From your other topics, I'm thinking you are talking about an AppleScriptObjC project, though - in that case, the various Cocoa methods need to be converted (see the AppleScriptObjC Release Notes), and delegate methods are placed in the main script object in the AppDelegate.applescript file:


on applicationShouldTerminateAfterLastWindowClosed_(sender)

returntrue

end applicationShouldTerminateAfterLastWindowClosed_

How to make an application close when window is closed?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.