nsworkspace

Open URL with Safari no matter what system browser is set to

三世轮回 提交于 2019-11-27 13:56:09
问题 In my objective-c program, I need to open a URL in Safari no matter what the system's default browser is. That means that this won't work, because it could launch Firefox or whatever other browser: NSWorkspace * ws = [NSWorkspace sharedWorkspace]; [ws openURL: url]; I think I'm close with this: [ws launchAppWithBundleIdentifier: @"com.apple.Safari" options: NSWorkspaceLaunchWithoutActivation additionalEventParamDescriptor: NULL launchIdentifier: nil]; only need to figure out how to pass in

unable to detect application running with another user (via switch user)

感情迁移 提交于 2019-11-27 02:56:05
问题 Use case : I login as " user1 " and launch Safari, then I click " user1 " on top-right corner and switch user to " user2 ". Now, I am trying to detect whether Safari is running for " user1 " but I am unable to do so with standard calls. I am using OS X 10.8 Mountain Lion for both development and running my code. I have used the following but in vain: [[NSWorkspace sharedWorkspace] runningApplications] - Safari not there in the list GetNextProcess() - Safari does not come up GetProcessForPID()