【发布时间】:2015-09-18 09:00:47
【问题描述】:
当我使用Alamofire 2 将我的项目升级到swift 2 时,headers 在代码中没有任何错误的情况下停止工作。原因是headers 不是老式的。
// login with Alamofire 1 and Swift 1.2 - WITH HEADER
func loginAlamofire_1(username:String) {
manager.session.configuration.HTTPAdditionalHeaders = ["Authorization": "yourToken"]
manager.request(.POST, "login_url", parameters: ["username" : username], encoding: ParameterEncoding.JSON)
.response{ (request, response, data, error) -> Void in
if error != nil{
print("error!")
} else {
print("welcome")
}
}
}
你可以在下面看到固定版本
【问题讨论】:
标签: ios swift swift2 alamofire