我正在使用Alamofire进行网络服务调用。我的问题是,应用程序需要时间来获得响应。是因为本地服务器吗?我的代码出了什么问题?
func checkSigninStatus() {
DispatchQueue.main.async {
let url = URL(string: ServiceUrl.loginStatus)!
let params: [String: String] = ["emailid": self.emailTxtField.text!, "password": self.passwordTxtField.text!, "mobileno": "0"]
Alamofire.request(url,method: .post ,parameters : params,encoding: JSONEncoding.default ,headers:headers).responseJSON {response in
switch response.result {
case .success:
if let data = response.result.value {
if (data as? Dictionary<String, Any> != nil) {
if let dictionaryArray = data as? Dictionary<String, Any> {
let receivedData = dictionaryArray["data"] as! Array<Dictionary<String, Any>>
if receivedData.count == 0 {
self.showAlert(title: "", message:"Invalid Username/Password", view: self)
} else {
// Tabbar
let storyBoard: UIStoryboard = UIStoryboard(name: "MenuStoryboard",
bundle: nil)
let newViewController1 = storyBoard.instantiateViewController(withIdentifier: "tabbar")
self.present(newViewController1, animated: true, completion: nil)
}
}
}
}
case .failure(let error):
print("RESPONSE ERROR: \(error)")
}
}
}
}