Check whether application already running
cocoa, macos
Solution
It sounds like you are saying you want to keep multiple instances of your cocoa app from running at the same time. Normally cocoa apps do not allow multiple instances to be running at the same time so typically you would not need to perform this check. Is there some specific circumstance in which you are finding that a cocoa app is being run concurrently?
In general, a cocoa way to solve this look at launchedApplications in NSWorkspace. This returns an NSArray containing a dictionary for each launched application. You can loop through the array to see if the app you are looking for is already running. I would advise that you use the value with the key NSApplicationBundleIdentifier which will have a value like "com.mycompany.myapp" rather than looking for the name. If you need to find the bundle identifier for an app you can look at its info.plist file in the app package.
Problem
I am developing an application in cocoa,which needs to check whether that app is already running at start up.If already running then i need to quit the new instance ..Is there any way to do this..Looking for a perfect solution