Is there an easy way to change the scheme of a NSURL? I do realize that NSURL is immutable. My goal is to change the scheme of an URL to \"https\" if t
NSURL
Swift5
extension URL { func settingScheme(_ value: String) -> URL { let components = NSURLComponents.init(url: self, resolvingAgainstBaseURL: true) components?.scheme = value return (components?.url!)! }
}
Usage
if nil == url.scheme { url = url.settingScheme("file") }