private func escapedParameters(parameters: [String:]) -> String { if parameters.isEmpty { return "" } else { var keyValuePairs = [String]() for(key, value) in parameters { let stringVavlue "\(value)" let escapeValue = stringValue. stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()) keyValuePairs.append(key + "=" + "\(escapedValue!)") } return "?\(keyValuePairs.joinWithSeparator("&"))" } }
let someParameters = [ "course": "networking", "hogehoge":"ios", "quiz":"escaping parameters" ] print(escapedParameters(someParameters))