【发布时间】:2015-10-23 17:06:57
【问题描述】:
我正在做一个使用 Swift 2.0 和 Alamofire 3 的小项目。 我需要发送到服务器的参数很少。
var myParameters = [
"myObjectName":"FooBar",
"myObjectId":123456
]
要发送数据,我有一个用 Alamofire 编写的基本请求
let myRequest = Alamofire.request(.POST, MY_SERVICE_URL, parameters: myParameters as! [String : AnyObject], encoding: .JSON)
我收到这样的回复:
myRequest.response { myRequest, myResponse, myData, myError in
/*
Here I would like to access myParameters, simply to double-check the ID of the data that I have sent out with myRequest.
*/
print("I'm Done with sending Object number \(myObjectId).")
}
是否有任何简单的方法可以将 myObjectId 传递给响应闭包?还是以其他方式访问它?
【问题讨论】: