我的 AFJSONRequestOperation 在 200 响应中遇到故障块。这是因为我有额外的 JSON 吗?
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *d = (NSDictionary *)responseObject;
bool required = [d[@"payment_required"] boolValue];
[self.delegate paymentRequired:required];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
int statusCode = operation.response.statusCode;
NSLog(@"status code: %d response: %@", statusCode, operation.responseString);
if (operation.response.statusCode == 402) {
[self.delegate paymentRequired:true];
return ;
}
[self handleOperationFailed:operation action:^{
[self determinePaymentRequired];
}];
}];
控制台中的产量
status code: 200 response: {'payment_required':'false'}
为什么会这样?