美文网首页
[AFJSONRequestSerializer request

[AFJSONRequestSerializer request

作者: 代码 | 来源:发表于2018-03-15 16:21 被阅读217次

在使用AFNetworking时,如果Url中包含空格,文字,或者特殊字符时,会崩溃:

[AFJSONRequestSerializer requestWithMethod:URLString:parameters:error:]

解决方法:NSString *url = [NSString stringWithFormat:@"你请求的链接"];

做以下处理:

NSString *requestUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; 

注意:有时候在链接换行处,可能存在空格,不容易发现;

相关文章

网友评论

      本文标题:[AFJSONRequestSerializer request

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