美文网首页
iOS URL编码 解码

iOS URL编码 解码

作者: MdWhat | 来源:发表于2017-11-07 13:15 被阅读254次

1.URL编码

NSString *encodeURL = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

2.URL解码

NSString *decodeURL = [url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

ios 9.0中已经替换此方法

//encode URL编码
NSString *str = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

//decode URL解码
NSString *decodedURL = [url stringByRemovingPercentEncoding];

相关文章

网友评论

      本文标题:iOS URL编码 解码

      本文链接:https://www.haomeiwen.com/subject/datjmxtx.html