Convert String to NSURL is return nil in swift 3/4 – Solution

Convert String to NSURL is return nil in swift 3/4 – Solution

let url : NSString = "url string here"
let urlStr : NSString = url.addingPercentEscapes(using: String.Encoding.utf8.rawValue)! as NSString
let actualURL : NSURL = NSURL(string: urlStr as String)!
print(actualURL)

Leave a Reply

Your email address will not be published. Required fields are marked *