我有一个名为GetCart()
GetCart()
功能是:
Alamofire.request(.GET, producturl, encoding: .JSON).validate() .responseJSON(completionHandler: {response in
switch response.result {
case .Success:
print("Validation Successful")
case .Failure(let error):
print(error)
}
})
这个GetCart()函数通过按钮操作方法在循环中传递:
@IBAction func calltwice(sender: UIButton) {
for all in 1...5{
GetCart("24485814")
}
}
首次尝试时会产生:
Validation Successful
Validation Successful
Validation Successful
Validation Successful
Validation Successful
第二次点击结果:
Error Domain=com.alamofire.error Code=-6006 "JSON could not be serialized. Input data was nil or zero length." UserInfo={NSLocalizedFailureReason=JSON could not be serialized. Input data was nil or zero length.}
Error Domain=com.alamofire.error Code=-6006 "JSON could not be serialized. Input data was nil or zero length." UserInfo={NSLocalizedFailureReason=JSON could not be serialized. Input data was nil or zero length.}
Error Domain=com.alamofire.error Code=-6006 "JSON could not be serialized. Input data was nil or zero length." UserInfo={NSLocalizedFailureReason=JSON could not be serialized. Input data was nil or zero length.}
Validation Successful
Validation Successful
无论第二次点击它循环次数(5或50),只有2次总是通过。 aynone会知道为什么会这样吗?