为什么dataTaskWithURL在iOS上工作,而在macOS上不工作?
错误信息是:
客户端错误:找不到具有指定主机名的服务器。
我的日程安排如下:
- (void)loadHTML {
NSString *urlString = @"https://morph.zone/modules/newbb_plus/viewtopic.php?topic_id=12630&forum=10";
NSURL *url = [NSURL URLWithString:urlString];
NSURLSessionDataTask *downloadTask = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error != nil) {
NSLog(@"Client-Error:%@",error.localizedDescription);
}
else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if (httpResponse.statusCode < 200 || httpResponse.statusCode > 299) {
NSLog(@"Server-Error:%ld",httpResponse.statusCode);
}
else {
NSLog(@"Data downloaded");
}
}
}];
[downloadTask resume];
}发布于 2019-09-22 04:53:18
https://stackoverflow.com/questions/58042612
复制相似问题