Reputation: 2181
Currently i am using the following way to encode the url
urlAndMethod.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
After encoding
http://103.50.154.52:8383/api/master/insta-list?category=Postpaid%20Mobile%20CDMA%20&%20Landline
How do i handle the special characters including '&'
Upvotes: 0
Views: 430
Reputation: 3526
You can use .urlHostAllowed
characterset.
let escapedString = someString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
Upvotes: 2