我試圖讓使用AFNetworking HTTP POST請求到我自己的服務器:AFNetworking遷移斯威夫特
let manager = AFHTTPSessionManager()
manager.post(
URL,
parameters: params,
success:
{
(operation, responseObject) -> Void in
if let response = responseObject as? [String: String] {
let alert = UIAlertController(title: response["status"],
message: response["message"],
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default) {_ in })
self.present(alert, animated: true)
}
},
failure:
{
(operation, error) -> Void in
self.handleError(error as NSError)
})
不過,我發現了以下錯誤:
post(_:parameters:success:failure:) is deprecated
我搜索AFNetworking遷移指南,但似乎只在Objective-C中提供說明,而不是Swift。我無法在Swift中找到新的post方法。有任何想法嗎?謝謝!
謝謝,這個工作! –