When using afn3.0
setDataTaskDidReceiveResponseBlock:
We made the following mistakes
Control reaches end of non-void block 。
This block should have a return value, but you didn’t report an error.
The specific uses are as follows:
AFHTTPSessionManager *httpMgr = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
NSURLSessionDataTask *task = [httpMgr HEAD:[self.url absoluteString] parameters:nil success:^(NSURLSessionDataTask * _Nonnull task) {
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
//By default, when the server response is received, the server thinks the client does not need to receive data, so the proxy method will not be called afterwards
// If you need to continue receiving data from the server, then you need to call block, and pass in the corresponding policy
/*
NSURLSessionResponseCancel = 0, Cancel task
NSURLSessionResponseAllow = 1, Receive task
NSURLSessionResponseBecomeDownload = 2, turn into a download
NSURLSessionResponseBecomeStream NS_ENUM_AVAILABLE(10_11, 9_0) = 3, turn into a stream
*/
[httpMgr setDataTaskDidReceiveResponseBlock:^NSURLSessionResponseDisposition(NSURLSession * _Nonnull session, NSURLSessionDataTask * _Nonnull dataTask, NSURLResponse * _Nonnull response) {
// If the NSURLSessionResponseDisposition method is not returned here, this error will be reported
// Solution Pass in the corresponding policy e.g.
return NSURLSessionResponseBecomeDownload;
}];
Or when using AFN’s download task:
[sessonMgr downloadTaskWithRequest:[NSURLRequest requestWithURL:self.url] progress:^(NSProgress * _Nonnull downloadProgress) {
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
// This error will also be reported if the stored directory is not returned here.
return [NSURL URLWithString:self.destPath];
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
}];
This question is answered on stackOverFlow: http://stackoverflow.com/questions/29631817/ios-objective-c-blocks-warning-control-reaches-end-of-non-void-function
Similar Posts:
- Android WebView monitors and rewrites window.history.go (- 1) method call
- System.Data.SqlTypes.SqlNullValueException: ‘Data is Null. This method or property cannot be called on Null values.’
- The interface method is not rewritten, and the idea does not report an error.
- [Solved] Mybatis error: attempted to return null from a method with a primitive return type (int)
- [Solved] Failed to replace a bad datanode on the existing pipeline due to no more good datanodes being available to try.
- The differences between response. Getwriter(). Write() and response. Getwriter(). Print(), as well as pritwriter object and out object
- [eslint] Unexpected block statement surrounding arrow body; move the returned value immediately a…
- How to Solve Curl pass large JSON files Error
- Solve the problem of “resource interpreted as document but transferred with MIME type application / JSON” in IE browser
- Strange frame error caused by incorrect use of flash. Redirect (‘/ path’) in flash