I am trying to create and display an UIalert for my app. The alert is inside of the view controller and it will be called inside the api service call as follows.
APIService().loginr(success: { result in
print(result!)
let json = result as! NSDictionary
self.showResponseAlert(title: "Success!", message: json["message"] as? String)
}, failure: {error in
print(error!)
}, parameters: parameters)
and my uiAlert
func showResponseAlert(title:String?,message:String?){
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default))
self.present(alert, animated: true, completion: nil)
}
and also i tried
DispatchQueue.main.async{
self.present(alertController, animated: true, completion: nil)
}
but didn't work for me.