用AFNetworking网络请求时出现_NSInlineData这种类型的乱码

AFHTTPSession Manager *manager = [AFHTTPSessionManager manager];

manager.requestSerializer = [AFHTTPRequestSerializer serializer];

NSMutableDictionary *params = [NSMutableDictionary dictionary];

params[@"account"] = _logInView.logUpView.phoneTF.text;

params[@"password"] = _logInView.logUpView.psdUpTF.text;

params[@"code"] = _logInView.logUpView.validationTF.text;

[manager POST:[kDomainBaseUrl stringByAppendingString:@"register"] parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {

} success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

NSString *token = responseObject[@"data"][@"token"];

[defaults setObject:token forKey:@"token"];

[defaults synchronize];

[self.logInView changState:_logInView.changBtn];

} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

}];

在设置manager的时候,如果有manager.responseSerializer = [AFHTTPResponseSerializer serializer];则返回的responseObject类型为_NSInlineData无法解析,应该写manager.requestSerializer = [AFHTTPRequestSerializer serializer];就好了。

你可能感兴趣的:(用AFNetworking网络请求时出现_NSInlineData这种类型的乱码)