Search code examples
objective-cmacoscocoasymlinknsapplication

Relaunching an already launched application


I have created an application for Mac OS X, and I have a desktop shortcut for it (created using ln -s). Now I want to add a feature such that whenever this shortcut is double clicked, with the application already running, some action should be performed (like opening a Finder window at a designated path). How can this be implemented?

I tried to create an observer for NSApplication-based notifications inside my application, but nothing constructive came of it.

Can anyone please help?


Solution

  • In your application's delegate, implement -applicationShouldHandleReopen:hasVisibleWindows: and do whatever you like.