I am using web view in my app, getting a URL from a text field. It works if the string starts with \"http://\". I am trying to modify the code so that it can also handle the
I solved like this, Swift 4 and up:
var yourString = "facebook.com" var urlPath = "" if yourString.contains(find: "https://") { urlPath = path } else { let newPath = "https://\(path)" urlPath = newPath } guard let url = URL(string: urlPath) else {return} UIApplication.shared.open(url)