swift 之url有中文参数

时间:2015-09-14 15:38:55   收藏:0   阅读:1155

URL带中文的问题:请求带中文的URL的资源时,比如:http://s237.sznews.com/pic/2010/11/23/e4fa5794926548ac953a8a525a23b6f2/竞赛资讯.png(可以在浏览器查看),

swift版代码

var url="http://s237.sznews.com/pic/2010/11/23/e4fa5794926548ac953a8a525a23b6f2/竞赛资讯.png"

var geturl=url.

stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!

直接用geturl就可

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!