Tuesday, May 1, 2018

Swift: fix invalid url

Some urls contain special characters or contain arabic words and when you parse this url on swift you will get "Invalid url request" error.

to resolve this problem it very easy but i take long time with searching on google about it after if find the solution :


feed?.link.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
let url = URL(string: (feed?.link)!)



Good Luck :)