when build my code then crash on Alamofire.request(request as! URLRequestConvertible).responseJSON()
. pls suggest how to fix this crash
let url = NSURL(string: "https://jsonplaceholder.typicode.com/users")
let request = NSMutableURLRequest(url:url! as URL)
request.httpMethod = "GET"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
Alamofire.request(request as! URLRequestConvertible).responseJSON(){ response in
switch response.result
{
case .success(let data):
print(" i got my Data Yup",data)
case .failure(let error):
print(error)
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…