swift URL生成

前端之家收集整理的这篇文章主要介绍了swift URL生成前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

猜你在找的Swift相关文章