Post

Replies

Boosts

Views

Activity

Reply to nw_protocol_error Crash on iOS 17.2 and later versions
NSOperationQueue * queue = [[NSOperationQueue alloc] init]; queue.maxConcurrentOperationCount = 1; NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; _session = [NSURLSession sessionWithConfiguration:config delegate:[XXWebImageWeakProxy proxyWithTarget:self] delegateQueue:queue]; …… _sessionTask = [_session dataTaskWithRequest:_request]; [_sessionTask resume]; -- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler { @autoreleasepool { NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; NSURLCredential *creadential = nil; if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { creadential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; if (creadential) { disposition = NSURLSessionAuthChallengeUseCredential; } else { disposition = NSURLSessionAuthChallengePerformDefaultHandling; } } else { if ([challenge previousFailureCount] == 0) { creadential = _credential; if (creadential) { disposition = NSURLSessionAuthChallengeUseCredential; } else { disposition = NSURLSessionAuthChallengePerformDefaultHandling; } } else { disposition = NSURLSessionAuthChallengePerformDefaultHandling; } } if (completionHandler) { completionHandler(disposition, creadential); } } }
Jan ’24