Reputation: 295
Question :: how to remove + from my string URL
Problem :: while calling API I am getting + symbol at the end of URL so how can I remove that +
Here is my code which removing space:
extension String {
func encodeURL() -> String {
return self.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())!
}
}
Upvotes: -1
Views: 1508
Reputation: 5554
If you want to get rid of ANY occurrences of '+' you could use this
let cleanString = self.stringByReplacingOccurrencesOfString("+", withString: "")
Upvotes: 2