let alert = UIAlertController(title: "비밀번호 바꾸기", message: "비밀번호를 바꾸시겠습니까 ?", preferredStyle: .alert)
        let success = UIAlertAction(title: "확인", style: .default) { action in
            print("확인 버튼이 눌렸습니다. \\(action)")
        }
        let cancel = UIAlertAction(title: "취소", style: .cancel) { cancel in
            print("취소 버튼이 눌렸습니다. \\(cancel)")
        }
        
        alert.addAction(success)
        alert.addAction(cancel)
        
        //present는 다음 화면을 부르는건데 UIAlertController 다음 화면임.
        present(alert, animated: true) {
            print("완료되었습니다.")
        }

addAction의 순서로 나열됨.

3개 이상부터는 ActionSheet를 사용하면 됨.

let alert = UIAlertController(title: "비밀번호 바꾸기", message: "비밀번호를 바꾸시겠습니까?", preferredStyle: .alert)
        
        let success = UIAlertAction(title: "확인", style: .destructive) { action in
            print("비밀번호 확인 버튼 클릭", action)
        }
        let cancel = UIAlertAction(title: "취소", style: .cancel) { action in
            print("비밀번호 취소 버튼 클릭", action)
        }
        alert.addAction(cancel)
        alert.addAction(success)
        
        to
        present(alert, animated: true) {
            print("alert 열기")
        }

Untitled