在alamofire響應中,我返回一些Bool
值。但它返回爲0
或1
而不是true
或false
。如何使Alamofire JSON響應將其返回爲true
或false
。這是我試過的代碼:iOS Swift Alamofire JSON響應將Bool值作爲'1'或'0'返回
Alamofire.request(baseurl, method: .get,encoding: JSONEncoding.default).responseJSON { response in
let statuscode = response.response?.statusCode
switch response.result
{
case .success(_):
if (statuscode == 200)
{
let JSON = response.result.value!
// I'm having some values like `isUserRegistered` is `true` or `false`. But it return as `0` or `1`.
}
case .failure(let error):
print("Request Failed With Error:\(error)")
}
}
使用它,你能告訴你的迴應? –