문제

I know I can use -openURL method in NSWorkspace class to open a URL. But because of some reason, I want to open a website via Safari instead of system default browser.

How can I achieve that?
BTW, this question is about OS X, not iOS.

thank you at advance!

도움이 되었습니까?

해결책

NSURL* url = [NSURL URLWithString: @"http://apple.com"];
[[NSWorkspace sharedWorkspace] openURLs:@[url]
                withAppBundleIdentifier:@"com.apple.Safari"
                                options:NSWorkspaceLaunchDefault
         additionalEventParamDescriptor:nil
                      launchIdentifiers:nil];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top