extension String{
func EncodeURL() -> String{
if let url = self.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet(charactersInString:"`#%^{}\"[]|\\<> ").invertedSet){
return url
}else{
return self
}
}
func EncodeURL(param : [String : AnyObject]?) -> String{
var param_url = Strings.empty
if(param != nil){
for item in param!{
param_url += "&" + item.0 + "=" + item.1.description
}
param_url = param_url.@H_502_109@replaceFirst(withString: "?")
}
param_url = self + param_url
return param_url.@H_502_109@EncodeURL()
}
}
原文链接:https://www.f2er.com/swift/324034.html