【发布时间】:2015-09-06 01:25:13
【问题描述】:
class ImageFetcher {
/* Initialize class variables and init function */
func fetch(){
var imageRequest = NSURLRequest(URL: self.source)
var imageDownload = NSURLDownload(request: imageRequest, delegate: self)
/* does path exist */
let directoryPath = self.destination.stringByDeletingLastPathComponent
let fileMgr = NSFileManager();
fileMgr.createDirectoryAtPath(directoryPath, withIntermediateDirectories: true, attributes: nil, error: nil)
imageDownload.setDestination(self.destination, allowOverwrite: true)
}
}
我遇到的问题是线路问题
var imageDownload = NSURLDownload(request: imageRequest, delegate: self)
它在抱怨“找不到接受类型为 '(request: NSURLRequest, delegate: ImageFetcher)' 的参数列表的类型 'NSURLDownload' 的初始化程序 我相信这与“自我”有关。我试图将它转换为 NSURLDownloadDelegate 但它抱怨它不能这样做。
有什么建议吗?
【问题讨论】: