Same as @KKRocks with update for swift 4.1.2
func queryItems(dictionary: [String:Any]) -> String {
var components = URLComponents()
print(components.url!)
components.queryItems = dictionary.map {
URLQueryItem(name: $0, value: String(describing: $1))
}
return (components.url?.absoluteString)!
}