Govind Rakholiya
Govind Rakholiya

Reputation: 295

How should I remove "+" from a string URL

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

Answers (1)

Russell
Russell

Reputation: 5554

If you want to get rid of ANY occurrences of '+' you could use this

let cleanString =  self.stringByReplacingOccurrencesOfString("+", withString: "")

Upvotes: 2

Related Questions