Encoding HTTP GET parameters

Use NSURLComponents to encode HTTP GET parameters:

Playground Icon

var urlComponents = URLComponents(string: "https://www.google.de/maps/")!
urlComponents.queryItems = [
    URLQueryItem(name: "q", value: String(51.500833)+","+String(-0.141944)),
    URLQueryItem(name: "z", value: String(6))
]
urlComponents.url      // returns https://www.google.de/maps/?q=51.500833,-0.141944&z=6
Btn training bbbdf557d2 Next iOS training: 10. - 14. September 2018, München
Btn read 3c0e607615 Read on: iOS developer blog
Btn subscribe 930758687e Subscribe: Email · Twitter
Btn share 3139847d21 Share: Email · Twitter
Btn support 789320554c Support the iOS developer blog - Become a patron
Btn about 5378472193 About me
Btn email 4d2439fc5b Email to Ralf Ebert «info@ralfebert.de»