我可以将图像发送到服务器,但我遇到了问题。我可以用这样的简单块检查失败:
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"success: %@", operation.responseString);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", operation.responseString);
}
];
[operation start];
但是我看不到这个块的发送进度。所以我找到了一个带有进度回调的特殊块,如下所示:
[operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
}];
[httpClient enqueueHTTPRequestOperation:operation];
问题是 setUploadProgressBlock 没有“失败:” ...
所以我的问题是......有一种方法可以检查发送是否失败?
谢谢你的帮助