'''
let fileURL: URL;
let destination: DownloadRequest.DownloadFileDestination = { _, _ in
return (fileURL, [.createIntermediateDirectories, .removePreviousFile])
}
'''
上面代码会报错,错误的原因是fileURL只是声明但是并没有初始化,初始化后就不回报错了,改成代码如下,错误就没有了,path只是我这里举个例子
'''
//获取沙盒路径
let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask,
true).last! as String
let fileURL: URL = URL(fileURLWithPath: path)
let destination: DownloadRequest.DownloadFileDestination = { _, _ in
return (fileURL, [.createIntermediateDirectories, .removePreviousFile])
}
'''
网友评论