Created
July 25, 2015 04:08
-
-
Save koogawa/f0987d6425a9da63d121 to your computer and use it in GitHub Desktop.
テスト:DictionaryからAPIに投げるSTRINGを作るメソッド #cswift #CodePiece
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
func buildQueryString(fromDictionary parameters: [String: String]) -> String { | |
var urlVars = [String]() | |
for (key, var val) in parameters { | |
val = val.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())! | |
urlVars += [key + "=" + "\(val)"] | |
} | |
return (!urlVars.isEmpty ? "?" : "") + join("&", urlVars) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment