All you need is:
guard let url = URL(string: "http://www.google.com") else {
return //be safe
}
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
More Related Contents:
- Type ‘Any’ Has no Subscript Members in Xcode 8.1 Swift 3
- Issue while adding action to UIButton in Swift 3.0
- DateFormatter doesn’t return date for “HH:mm:ss”
- Swift saving and retrieving custom object from UserDefaults
- AnyObject not working in Xcode8 beta6?
- Closure cannot implicitly capture a mutating self parameter
- Type ‘Any’ Has no Subscript Members in xcode 8 Swift 3 [duplicate]
- Extract RGB Values From UIColor
- How to implement method swizzling swift 3.0?
- How to create managedObjectContext using Swift 3 in Xcode 8?
- Xcode 9 Swift Language Version (SWIFT_VERSION)
- Strange generic function appear in view controller after converting to swift 3
- Difference between DispatchQueue.main.async and DispatchQueue.main.sync
- Swift 3 Core Data Delete Object
- Using ScrollView Programmatically in Swift 3
- Add custom controls to AVPlayer in swift
- custom interactive transition animation
- Can’t Hide Status Bar—Swift 3, [duplicate]
- Redirect NSLog to File in Swift not working
- How to post nested json by SwiftyJson and Alamofire?
- How to push and present to UIViewController programmatically without segue in iOS Swift 3
- Swift – Cut hole in shadow layer
- Why would a `scheduledTimer` fire properly when setup outside a block, but not within a block?
- Using SecRandomCopyBytes in Swift
- UITableViewCell Buttons with action
- Create Directory in Swift 3.0
- Hide the status bar in ios 9
- Swift 3: Unrecognized selector sent to instance Xcode 8 [duplicate]
- How to Read Plist without using NSDictionary in Swift?
- main.async vs main.sync() vs global().async in Swift3 GCD