extension UIViewController {
func alert(_ message: String, completion: (()->Void)? = nil) {
DispatchQueue.main.async {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
let okAction = UIAlertAction(title: "확인", style: .cancel) { (_) in
completion?()
}
alert.addAction(okAction)
self.present(alert, animated: false)
}
}
}
사용할 때에는 아무데서나
self.alert("알림메시지!!!")
이렇게 사용하면 된다 😎