无法调用非函数类型'HTTPURLResponse?'的值Alamofire 4,Swift 3
问题描述:
我想用Alamofire发邮件给Mailgun。我正在使用下面的代码发送请求,但我从.response
开始在线获得错误Cannot call value of non-function type 'HTTPURLResponse?'
。无法调用非函数类型'HTTPURLResponse?'的值Alamofire 4,Swift 3
我该如何解决这个问题?我试图复制在这里找到的代码,但更新为Swift 3.我试图用Mailgun和Alamofire发送电子邮件。
https://gist.github.com/makzan/11e8605f85352abf8dc1/
谢谢!
Alamofire.request(url, method: .post, parameters: parameters)
.authenticate(user: "api", password: key)
.response{ (request, response, data, error) in
println(request)
println(response)
println(error)
}
}
答
对于这类问题,值得关注一下Alamofire migration pages。
你会看到那里的反应,现在像这样的处理:
// Alamofire 3
Alamofire.request(.GET, urlString).response { request, response, data, error in
print(request)
print(response)
print(data)
print(error)
}
// Alamofire 4
Alamofire.request(urlString).response { response in // method defaults to `.get`
debugPrint(response)
}
这是它,谢谢!不知道我是如何错过它的 – winston