【发布时间】:2015-08-11 03:39:53
【问题描述】:
我正在使用 alamofire 主分支。
我的代码是这样的:
private func startDownLoad() {
Alamofire.download(.GET, REMOTE_TESTSET_URL,
{ (temporaryURL, response) in
if let directoryURL = NSFileManager.defaultManager().URLsForDirectory(
.DocumentDirectory, inDomains: .UserDomainMask)[0] as? NSURL {
let pathComponent = response.suggestedFilename
let fileUrl = directoryURL.URLByAppendingPathComponent(pathComponent!)
if let fullPath = fileUrl.absoluteString {
if NSFileManager.defaultManager().fileExistsAtPath(fullPath) {
NSFileManager.defaultManager().removeItemAtPath(fullPath, error: nil)
}
}
return fileUrl
}
return temporaryURL
}
).progress( closure: { (bytesRead, totalBytesRead, totalBytesExpectedToRead) in
println("download set progress")
self.delegate.onDownLoadProgress(Int(totalBytesRead), total: Int(totalBytesExpectedToRead))
}).response { (request, response, _, error) in
if nil == error {
NSUserDefaults.standardUserDefaults().setValue(self.currentVersion, forKey: KEY_TEST_SET_VERSION)
self.delegate.onDownLoadFinish(STATUS_DOWNLOAD_SUCCESS)
} else {
self.delegate.onDownLoadError(ERROR_UNKNOWN_ERROR)
}
}
}
但是编译器抱怨:
“无法使用类型为 '((_, _, _, _) -> _) 的参数列表调用 'response'”
那么,有什么想法吗?谢谢。
【问题讨论】:
-
会不会是因为在“response”和“progress”参数中,你多放了
(),设置是参数列表? -
恐怕不行。我删除( ),但错误仍然存在