How do I convert the string "ff \" ff "to NSURL?

It turns out like this:

let str = "ff\"ff" //ff"ff let url = NSURL(string: str) //nil 

And it is necessary that print (url) give out ff "ff.

    1 answer 1

    The character "is denoted as% 22, i.e. to get the NSURL =" ff "ff" link from String = "ff \" ff ", you need to initialize the NSURL with the string" ff% 22ff ".

     let str = "ff%22ff" let url = NSURL(string: str) print(url) // ff"ff