回答:
わかりました、操作オブジェクトで答えを見つけました
failure:^(AFHTTPRequestOperation *operation, NSError *error){
NSLog(@"error code %d",[operation.response statusCode]);
}];
AFNetworking 3.0の場合は、
failure:^(NSURLSessionTask *operation, NSError *error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)operation.response;
httpResponse.statusCode;
NSLog(@"status code: %li", (long)httpResponse.statusCode);
}
NSInteger operationStatusCode = [operation.error code];
NSInteger httpStatusCode = operation.response.statusCode;
リクエストがキャンセルされた/到達できない/タイムアウトした場合httpStatusCodeは、常にになります0。
または、を理解することで問題を特定できますoperationStatusCode。これは、あるNSErrorオブジェクト。
operationStatusCodeなります-1009。operationStatusCodeすると、になります-999。AppleのドキュメントNSErrorで他のすべてのコードとその説明を確認できます
それは私のために働きますあなたの要求に以下の行を追加してください
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[operation.request HTTPMethod]