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)它抱怨说,“无法找到接受类型参数列表的'NSURLDownload‘初始化器’(请求: NSURLRequest,委托: ImageFetcher)‘我认为它与”自我“有关。我试图把它转换为一个NSURLDownloadDelegate,但它抱怨说它做不到。”
有什么建议吗?
发布于 2015-09-06 01:36:11
请把你的课做得很好,如:
class ImageFetcher : NSObject, NSURLDownloadDelegate {然后用以下方式调用init行:
var imageDownload = NSURLDownload(request: imageRequest, delegate: self)https://stackoverflow.com/questions/32419162
复制相似问题