Opening web URL with NSButton - Mac OS
This should work:
-(IBAction)pushApp1:(id)sender {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://stackoverflow.com"]];
}
Code for Swift 3
@IBAction func pushApp1(_ sender: Any) {
NSWorkspace.shared().open(URL(string: "http://stackoverflow.com")!)
}
swift 5:
@IBAction func gotoSite(_ sender: Any) {
if let url = URL(string: OFFICIAL_SITE_URL) {
NSWorkspace.shared.open(url)
}
}