Swift 3 or later
import Cocoa
let url = URL(string: "https://www.google.com")!
if NSWorkspace.shared.open(url) {
print("default browser was successfully opened")
}
More Related Contents:
- NSTimer not firing when NSMenu is open in Swift
- TableViewCell in Swift?
- Expected Declaration Error using Swift
- Do Swift-based applications work on OS X 10.9/iOS 7 and lower?
- Change templates in Xcode
- Can I have multiple Xcode versions installed?
- Error “Thread 1: breakpoint 2.1”
- IBOutlet is nil, but it is connected in storyboard, Swift
- GFortran error: ld: library not found for -lSystem when trying to compile
- how to resize a bitmap on iOS
- “Use of undeclared type” in Swift, even though type is internal, and exists in same module
- Installing Apple’s Network Link Conditioner Tool
- Xcode is not currently available from the Software Update server
- x86 Assembly on a Mac
- Permanently configuring LLDB (in Xcode 4.3.2) not to stop on signals
- How to upload dmg file for notarization in xcode
- How can I use swift in Terminal?
- Setting GCC 4.2 as the default compiler on Mac OS X Leopard
- How can I make a countdown with NSTimer?
- Compile OpenCV (2.3.1+) for OS X Lion / Mountain Lion with Xcode
- How do I debug SwiftUI AttributeGraph cycle warnings?
- Redundant conformance error message Swift 2
- How to manually create icns files using iconutil?
- How do you update Xcode on OSX to the latest version?
- Class variables not yet supported
- How to present a modal atop the current view in Swift
- Testing if an element is visible with Xcode 7 UITest
- Error when with Xcode 5.0 and Rcpp (Command Line Tools ARE installed)
- Swift Playground – Files are not readable
- iAd in xcode 6 with Swift