A very simple question, how do I replace the first character of a string. I'm probably doing something totally wrong, but I simply can't get it to work.
I have tried this: var query = url.query!.stringByReplacingOccurrencesOfString("&", withString: "?", options: NSStringCompareOptions.LiteralSearch, range: NSMakeRange(0, 1))
But it gives me the following error:
Cannot invoke 'stringByReplacingOccurrencesOfString' with an argument list of type '(String, withString: String, options: NSStringCompareOptions, range: NSRange)'
When I remove the NSMakeRange and change it to nil, it works, but it replaces all the &'s in the string.
nil
as therange
, of course it will replace all the&
characters as you are usingstringByReplacingOccurrencesOfString
. – Kyle Emmanuel