Assertion failure in -[AFJSONRequestSerializer requestWithMethod:URLString:parameters:error:]

AFN 网络请求,报错:Assertion failure in -[AFJSONRequestSerializer requestWithMethod:URLString:parameters:error:]

解决办法把请求的url 做如下操作:

 

urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

附加:

stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet] 这个方法是用来进行汉字转码的。

我请求的URL 里面有中文,才会报以上的错误。

猜你喜欢

转载自www.cnblogs.com/kimiyo/p/11388915.html