1

i want to look up cities for a weather application. iOS [Swift] The webservice has a built in accuracy search, so i just have to pass the string to the url.

var searchedCity:String = searchBar.text
searchedCity = searchedCity.stringByReplacingOccurrencesOfString(" ", withString: "_", options: NSStringCompareOptions.LiteralSearch, range: nil)

The 2nd line will change the space characters to underscore characters:

" " -> "_" example: ( Los Angeles to Los_Angeles )

Thats fine, but how can i replace all the special characters to english characters, or URL acceptable characters.

example characters to replace: áéíöóőüúű to aeiooouuu

Or, if there is any other way to force the keyboard to use only english characters, please let me know.

Thanks for the help!

1 Answers1

0

Have you looked at url encoding/decoding?

More details on that can be found here

Swift - encode URL

Community
  • 1
  • 1
Rajeev Bhatia
  • 2,974
  • 1
  • 21
  • 29