|
@@ -119,27 +119,28 @@
|
|
|
self.af_URLSessionTask = nil;
|
|
|
|
|
|
__weak __typeof(self)weakSelf = self;
|
|
|
- NSURLSessionDataTask *dataTask;
|
|
|
+ __block NSURLSessionDataTask *dataTask;
|
|
|
dataTask = [self.sessionManager
|
|
|
- GET:request.URL.absoluteString
|
|
|
- parameters:nil
|
|
|
- progress:nil
|
|
|
- success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
|
|
|
- __strong __typeof(weakSelf) strongSelf = weakSelf;
|
|
|
- if (success) {
|
|
|
- success((NSHTTPURLResponse *)task.response, responseObject);
|
|
|
- }
|
|
|
- [strongSelf loadData:responseObject MIMEType:MIMEType textEncodingName:textEncodingName baseURL:[task.currentRequest URL]];
|
|
|
-
|
|
|
- if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
|
|
|
- [strongSelf.delegate webViewDidFinishLoad:strongSelf];
|
|
|
- }
|
|
|
- }
|
|
|
- failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
|
|
|
- if (failure) {
|
|
|
- failure(error);
|
|
|
- }
|
|
|
- }];
|
|
|
+ dataTaskWithRequest:request
|
|
|
+ uploadProgress:nil
|
|
|
+ downloadProgress:nil
|
|
|
+ completionHandler:^(NSURLResponse * _Nonnull response, id _Nonnull responseObject, NSError * _Nullable error) {
|
|
|
+ __strong __typeof(weakSelf) strongSelf = weakSelf;
|
|
|
+ if (error) {
|
|
|
+ if (failure) {
|
|
|
+ failure(error);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (success) {
|
|
|
+ success((NSHTTPURLResponse *)response, responseObject);
|
|
|
+ }
|
|
|
+ [strongSelf loadData:responseObject MIMEType:MIMEType textEncodingName:textEncodingName baseURL:[dataTask.currentRequest URL]];
|
|
|
+
|
|
|
+ if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
|
|
|
+ [strongSelf.delegate webViewDidFinishLoad:strongSelf];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }];
|
|
|
self.af_URLSessionTask = dataTask;
|
|
|
if (progress != nil) {
|
|
|
*progress = [self.sessionManager downloadProgressForTask:dataTask];
|