Хотите отобразить пользовательское сообщение об ошибке?
если это так, добавьте строку ошибки в ваше завершение завершения
func loginApiCall(email : String,password : String, completion:@escaping (_ isSuccesfull :Bool, _ errorMessage :String?) ->())
, а затем, когда произойдет сбой входа в систему при изменении класса API на
if msg == "error" {
// show alert in Login VC during api call
completion(false, "Your Error Message!")
print("Validation error")
}
тогда в вашем контроллере вида входа обработайте его
apiCall.loginApiCall(email: email, password: password) { success,errorMessage in
if success {
// show alert here which is highlighted in api class
print("successful")
self.hideActivityIndicator(uiView: self.view)
self.mainView.isHidden = true
self.networkView.isHidden = true
self.performSegue(withIdentifier: "LogToWorkSpace", sender: nil)
} else {
if let message = errorMessage
{
DispatchQueue.main.async {
let otherAlert = UIAlertController(title: "Error!", message: message, preferredStyle: UIAlertControllerStyle.alert)
let dismiss = UIAlertAction(title: "OK", style: UIAlertActionStyle.cancel, handler: nil)
otherAlert.addAction(dismiss)
self.present(otherAlert, animated: true, completion: nil)
print("not successful")
}
}
}
}