源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

iOS开发中不合法的网络请求地址如何解决

  • 时间:2022-07-11 17:06 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:iOS开发中不合法的网络请求地址如何解决
NSString *const kWebsite = @[url=http://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fr=&sf=1&fmq=1459502303089_R&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&word=%E9%A3%8E%E6%99%AF]http://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fr=&sf=1&fmq=1459502303089_R&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&word=风景[/url];
这是一个百度图片风景分类里的图片地址,当我发送请求时发生Unsuppotedurl错误 [img]http://files.jb51.net/file_images/article/201609/201609040843361.png[/img] 百度了一下,产生错误的原因是URL 不能包含 ASCII 字符集,汉字, 这样的字符必须进行转义的字符
NSString *urlString = [kWebsite stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
以上所述是小编给大家介绍的iOS开发中不合法的网络请求地址的全部叙述,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部