When clicking on an app icon in the dock after it's opened, what event can I receive?

macos, swift

Solution

Implement

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool)

In your AppDelegate and make your application visible there.

See the documentation on more implementation details

Problem

I am building an OS X app in Swift: (1) Run the app (2) The app starts and the app icon appears in the dock. (3) Clicking on the app icon in the dock <-- How can my app get notification for this action? I hope to do something after the user click the app icon in the dock when the app is running. How to get notified for this action?

Original source