func makePopup(popupTitle:String, popupMessage:String) { let controller = UIAlertController( title: popupTitle, message: popupMessage, preferredStyle: .alert) controller.addAction(UIAlertAction(title: "OK", style: .default)) present(controller,animated:true) } // Call it this way: makePopup(popupTitle: "Error:", popupMessage: "You didn't enter a value")