AFN經典報錯bug(三)php
1. 報錯以下:ios
[NSURL length]: unrecognized selector sent to instance 0x7fcbb2e72440json
2.打全局斷點api
鎖定到 NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];url
3.緣由是因爲 url 類型不匹配spa
NSString * _urlStr = @"http://iosapi.baidu.cn/doctor/matchedDoctorCount.json.php";orm
NSURL * _url = [NSURL URLWithString:_urlStr];string
[_httpManger POST:_url parameters:parameters progress:^(NSProgress * _Nonnull uploadProgress) {it
NSLog(@"uploadProgress------------------%@",uploadProgress);io
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"responseObject------------------%@",responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"error------------------%@",error);
}];
4. 須要nsstring類型 拼接的是NSURL類型
5.修改 [_httpManger POST:_urlStr parameters:parameters progress:^(NSProgress * _Nonnull uploadProgress) {
NSLog(@"uploadProgress------------------%@",uploadProgress);
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"responseObject------------------%@",responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"error------------------%@",error);
}];
6. 運行success