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) {
}];
在設(shè)置manager的時(shí)候,如果有manager.responseSerializer = [AFHTTPResponseSerializer serializer];則返回的responseObject類型為_NSInlineData無法解析,應(yīng)該寫manager.requestSerializer = [AFHTTPRequestSerializer serializer];就好了贷掖。