AFNetworking请求中含有中文时程序崩溃
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];