URLEncode
extension String {
// URL Decode
func URLDecode() -> String? {
return self.stringByRemovingPercentEncoding // stringByReplacingPercentEscapesUsingEncoding
is deprecated
}
// URL Encode
func URLEncode() -> String? {
return self.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet(charactersInString: "!*'\"();:@&=+$,/?%#[]% ").invertedSet) // `CFURLCreateStringByAddingPercentEscapes` is deprecated
}
}
URLDecode
url.absoluteString.stringByRemovingPercentEncoding
网友评论