Created
June 21, 2016 11:03
-
-
Save stinger/06d5260d63b4c887d560d61ade8e8a66 to your computer and use it in GitHub Desktop.
Swift 3: Using URLComponents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: # Swift 3: Using URLComponents | |
import Foundation | |
//: ### Compose the componens | |
var url = URLComponents() | |
url.scheme = "http" | |
url.host = "google.com" | |
//: ### Pass the query string parameters | |
url.queryItems = [ | |
URLQueryItem(name: "test", value: "data"), | |
URLQueryItem(name: "foo", value: "bar") | |
] | |
//: ### Output the formatted URL | |
print(url.string!) | |
//: ### Output the formatted query string | |
print(url.query!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment