I need to send an URL in Arabic language, so I need to encode it before I put it in URL. I am using Swift code.
Below is an example what i really need
var s = "www.example.com/السلام عليكم"
let url = NSURL(string : s)
So the word (السلام عليكم) is in Arabic characters that what I want to send.
swift 4 we face the same problem it solved by this way
Swift 2.0
Swift 3
You need to encode url as you have written. You can do so with that string method:
So your code will be:
you have to Encode this URL before sending this URL
To improve @Druva's answer create an extention somewhere in the project
Swift 2.0
Swift 3.0
You need to encode this string as it contains special characters.
where encodedURL is your final URL