【发布时间】:2017-01-22 21:09:45
【问题描述】:
我收到此错误:
"不能调用非函数类型'HTTPURLResponse?'的值"
关于部分:
.response { (request, response, data, error)
我想知道是否有人可以帮助我。
Alamofire.download(urlToCall, method: .get) { temporaryURL, response in
if FileManager.default.fileExists(atPath: finalPath!.path!) {
do {
try FileManager.default.removeItem(atPath: finalPath!.path!)
} catch {
// Error - handle if required
}
}
return finalPath!
}
.response { (request, response, data, error) in
if error != nil {
}
var myDict: NSDictionary?
let path = finalPath!
myDict = NSDictionary(contentsOf: path)
if let dict = myDict {
success(dict)
}
if finalPath != nil {
//doSomethingWithTheFile(finalPath!, fileName: fileName!)
}
}
【问题讨论】:
-
不。类似的问题,但不一样。 swift 和 alamofire 的不同版本。
-
您的目标是 iOS 8 吗?我不知道原因,但用于 Swift 3 的 Alamofire 必须至少是 iOS 9。问候
-
@JordanClark - 也许不同的版本,但问题是一样的。您的闭包参数不正确。
-
顺便说一句,你的服务器真的发回了
NSDictionary的plist吗?这有点不寻常。通常是 JSON 或类似的。