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("์๋ฆผ๋ฉ์์ง!!!")
์ด๋ ๊ฒ ์ฌ์ฉํ๋ฉด ๋๋ค ๐