Objective-c – How would you make The Dock Icon show a window when clicked

cocoaobjective c

I would like the Dock Icon to use the method makekeyandorderfront to open the Main window after it has been closed. I have done this with a button opening a Window but I don't know how to do it with the Dock Icon because you can't make a connection to it in interface builder.

Best Answer

There's a delegate method in NSApplication's delegate:

- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag;

which you can use to handle clicks on the app's icon in the dock. See its documentation.

Related Topic