在macOS 10.13中运行我的macOS应用程序,我看到打印到控制台:
Scheduling the NSURLDownload loader is no longer supported.
这是什么意思?
答案 0 :(得分:5)
Sparkle Updater似乎是我找到的实例中的罪魁祸首。我猜Sparkle开发团队将会参与其中,希望我们在Sparkle更新后不会再看到这条消息了。
答案 1 :(得分:3)
它似乎意味着您刚刚创建了一个已弃用的类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
我会说&#34;修复&#34;是用NSURLSession替换已弃用的NSURLDownload。
答案 2 :(得分:0)
您可以直接在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];