在macOS 10.13中运行我的macOS应用程序,我看到打印到控制台:
Scheduling the NSURLDownload loader is no longer supported.这是什么意思?
发布于 2017-10-13 07:54:45
在我发现的实例中,Sparkle Updater似乎是罪魁祸首。我猜Sparkle开发团队会关注它,希望在Sparkle更新后我们不会再看到这条消息。
发布于 2017-09-07 14:01:53
这似乎意味着您刚刚创建了一个已弃用的类NSURLDownload的实例。
为了显示这一点,在Xcode中创建一个新的Cocoa命令行工具项目,并将main.m中的代码替换为以下代码:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSURL* url = [[NSURL alloc] initWithString:@"https://example.com"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:30.0];
NSLog(@"Will print strange sentence to console") ;
[[NSURLDownload alloc] initWithRequest:request
delegate:nil];
NSLog(@"Did print strange sentence to console") ;
}
return 0;
}构建并运行。我在控制台中得到了以下结果(去掉时间戳):
Will print strange sentence to console:
Scheduling the NSURLDownload loader is no longer supported.
Did print strange sentence to console我要说的是,“修复”是用NSURLSession替换过时的NSURLDownload。
发布于 2017-11-23 04:36:05
您可以直接在Sparkle的源代码中对其进行更正。通过将NSURLDownload替换为以下内容来更新第82行的SUAppcast.m文件:
NSURLSessionDownloadTask *downloadTask = [[NSURLSession sharedSession] downloadTaskWithRequest:request completionHandler:^(NSURL *location, __unused NSURLResponse *response, NSError *error) {
if (location) {
NSString *destinationFilename = NSTemporaryDirectory();
if (destinationFilename) {
// The file will not persist if not moved, Sparkle will remove it later.
destinationFilename = [destinationFilename stringByAppendingPathComponent:@"Appcast.xml"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *anError = nil;
NSString *fromPath = [location path];
if ([fileManager fileExistsAtPath:destinationFilename])
[fileManager removeItemAtPath:destinationFilename error:&anError];
BOOL fileCopied = [fileManager moveItemAtPath:fromPath toPath:destinationFilename error:&anError];
if (fileCopied == NO) {
[self reportError:anError];
} else {
self.downloadFilename = destinationFilename;
dispatch_async(dispatch_get_main_queue(), ^{
[self downloadDidFinish:[[NSURLDownload alloc] init]];
});
}
}
} else {
[self reportError:error];
}
}];
[downloadTask resume];https://stackoverflow.com/questions/46088843
复制相似问题