利用AFN請求網路資料時出錯。(Assertion failure in -[AFHTTPRequestSerializer requestWithMethod:URLString:paramete)
阿新 • • 發佈:2019-02-06
AFNetworking請求中含有中文時程式崩潰
AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];[manager GET:urlString parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {//} failure:^(AFHTTPRequestOperation *operation, NSError *error) {//}];
出現error:
Assertion failure in -[AFHTTPRequestSerializer requestWithMethod:URLString:parameters:error:]
需要處理urlString的編碼
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
注意:檢視請求的介面是否正確。