Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#9 assignment 4 #12

Merged
merged 12 commits into from
Nov 29, 2021
Merged

Feature/#9 assignment 4 #12

merged 12 commits into from
Nov 29, 2021

Conversation

yangsubinn
Copy link
Member

๐Ÿ“Œ ๊ด€๋ จ ์ด์Šˆ

closed #9

๐Ÿ“Œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ ๋ฐ ์ด์œ 

  • ํ™”๋ฉด์ „ํ™˜ ๋ณ€๊ฒฝ
  • ๋กœ๊ทธ์ธ ์„œ๋ฒ„ ์—ฐ๊ฒฐ
  • ํšŒ์›๊ฐ€์ž… ์„œ๋ฒ„ ์—ฐ๊ฒฐ
  • UserDefaults ์‚ฌ์šฉ

ezgif com-gif-maker (17)

๐Ÿ“Œ PR Point

๊ฐ€์žฅ ๊ณ ๋ฏผ๋๋˜ ๋ถ€๋ถ„์€ pathErr์ผ ๋•Œ ๋ฉ”์„ธ์ง€๋ฅผ ๋ฐ›์•„์™€์„œ ๋„์›Œ์ฃผ๋Š” ๋ถ€๋ถ„์ด์—ˆ๋Š”๋ฐ
networkRestult์—์„œ pathErr๋„ ๊ฐ’์„ ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์„œ ๊ตฌ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค..

๋˜ ํ•˜๋‹ค๋ณด๋‹ˆ ์ด ์ „์— ์—ฐ๊ฒฐํ–ˆ๋˜ ํ™”๋ฉด ์ „ํ™˜์ด๋ž‘ present.. push ... ๋ง‰ ๊ผฌ์ด๋Š” ๊ฒƒ ๊ฐ™์•„์„œ ํ˜ผ๋ž€์Šค๋Ÿฌ์› ๋Š”๋ฐ
์•„๋ž˜์ฒ˜๋Ÿผ ๊ตฌ์„ฑํ–ˆ์Šด๋‹ค ์ œ๊ฐ€ ํ•˜๋‹ค๋ณด๋‹ˆ ๋จธ๋ฆฟ์†๋„ ๋ง‰ ๊ผฌ์ด๋Š” ๊ฒƒ ๊ฐ™์•„์„œ ๊ทธ๋ ค๋ดค๋Š”๋ฐ ์ดํ•ดํ•˜๋Š”๋ฐ์— ์ชผ๊ธˆ์ด๋ผ๋„ ๋„์›€์ด ๋˜์‹œ๋ผ๊ตฌ ์˜ฌ๋ ค๋ด…๋‹ˆ๋‹ค..
Slide 16_9 - 5

๐Ÿ“Œ ์ฐธ๊ณ  ์‚ฌํ•ญ

์„œ๋ฒ„ ๋„ˆ๋ฌด ์–ด๋ ค์›Œ์„œ ๋ˆˆ๋ฌผ์ด ์ฃผ๋ฅต์ฃผ๋ฅต ๋‚˜์š”
์ผ๋‹จ ์–ด์งธ์ €์งธ ๊ตด๋Ÿฌ๊ฐ€๋„๋ก ํ•˜๊ธด ํ–ˆ๋Š”๋ฐ ๋‹ค์†Œ ์–ผ๋ ๋šฑ๋•…ํ•œ ๊ฒƒ ๊ฐ™๋„ค์—ฌ.. ์ด๊ฒŒ ๋งž๋‚˜..
๋” ์ข‹์€ ๋ฐฉ๋ฒ•์ด๋‚˜ ์ด์ƒํ•œ ๋ถ€๋ถ„์ด๋‚˜ ๋ง˜์— ์•ˆ๋“œ๋Š” ๋ถ€๋ถ„ ๋“ฑ๋“ฑ์ด ์žˆ๋‹ค๋ฉด ๋‹ค ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ์ œ๊ฐ€... ์—ด์‹ฌํžˆ ๋ณด๊ฒ ์Šด๋‹ˆ๋‹ค

Copy link

@hwangJi-dev hwangJi-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๋‹ˆ ์ˆ˜๋นˆ์”Œ,,, ๋„ˆ๋ฌด ์ž˜ํ•˜์…จ๋Š”๋ฐ์š” ,,, , ,, , ,,, ๋ง์„ ์žƒ์—ˆ๋‹ค..
์นœ์ ˆํ•˜๊ฒŒ ํ™”๋ฉด์ „ํ™˜ ์„ค๋ช…ํ•ด์ค€ ๊ฒƒ๋„ ๋„˜ ๊ณ ๋งˆ์›Œ >,< ์ตœ๊ณ ์–Œ๐Ÿ’œ

๊ทธ๋ฆฌ๊ณ  ๋‚˜๋Š” PathErr์—์„œ๋Š” ์—๋Ÿฌ๋ฉ”์‹œ์ง€๋ฅผ ์•ˆ๋ฐ›์•„์˜ค๊ณ  requestFail์ผ ๋•Œ๋งŒ ์—๋Ÿฌ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ›์•„์™”์–ด!

๋ณดํ†ต path err๋Š” ๊ฒฝ๋กœ ์—๋Ÿฌ๋ผ์„œ path err๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด ์šฐ๋ฆฌ๊ฐ€ ์š”์ฒญ ๋ณด๋‚ด๋Š” ๊ฒฝ๋กœ๊ฐ€ ์ž˜๋ชป๋œ ๊ฒฝ์šฐ์ž–์•„!!
๊ทธ๋ž˜์„œ path err์—๋Œ€ํ•ด์„œ๋Š” ์‘๋‹ต๋ฌธ์ด request err์ฒ˜๋Ÿผ ์—ฌ๋Ÿฌ๊ฐ€์ง€๋กœ ๋‚˜๋ˆ ์ ธ์„œ ์˜ค์ง€ ์•Š๋Š” ํŽธ์ด๋ผ (์„œ๋ฒ„์—์„œ๋„ path err์— ๊ด€ํ•œ ์—๋Ÿฌ ํ•ธ๋“ค๋ง์€ ํ•œ๋ฒˆ๋งŒ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์•„๊ฐ€์ง€๊ณ ,,) ๊ทธ๋ฆฌ๊ณ  msg๋ฅผ ๋ฐ›์•„์™€์„œ alert๋กœ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋„์šธ ํ•„์š”๊ฐ€ ์—†์œผ๋‹ˆ๊นŒ (ํด๋ผ ๋‹จ์—์„œ๋งŒ ์•Œ์•„๋‘๋ฉด ๋  ์—๋Ÿฌ๋ผ๊ณ  ์ƒ๊ฐ๋ผ์„œ print๋ฌธ์œผ๋กœ๋งŒ ์‹๋ณ„ํ•ด๋„ ๊ดœ์ฐฎ๋‹ค๊ณ  ์ƒ๊ฐํ•ด์จ!)
๊ทธ๋ž˜์„œ request err์ผ๋•Œ๋งŒ ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ›์•„์™€์คฌ์–ด!

์ด๋ ‡๊ฒŒ ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ๋‹ค๊ตฌ ์•Œ๋ ค์ฃผ๊ณ  ์‹ถ์–ด์„œ!!! :)

private func judgeData(status: Int, data: Data) -> NetworkResult<Any> {
        let decoder = JSONDecoder()
        guard let decodedData = try? decoder.decode(GenericResponse<SignResultData>.self, from: data) else {
            return .pathErr }
        
        switch status {
        case 200:
            return .success(decodedData.data ?? "None-Data")
        case 400:
            return .requestErr(decodedData.message)
        case 404:
            return .pathErr
        case 500:
            return .serverErr
        default:
            return .networkFail
        }
    }

์ˆ˜๋นˆ์ด ๊ณ ์ƒํ•ด์จ ์ด๋ฒˆ์ฃผ๋‘ ๐Ÿ‘๐Ÿป

/// Main ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ LoginVC -> Main ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ SuccessVC
guard let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "SuccessVC") as? SuccessVC else {return}

nextVC.message = self.nameTextField.text

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๋ถ€๋ถ„์€ SuccessVC์—์„œ UserDefaults๋กœ ๊ฐ’ ์„ค์ •ํ•ด์ฃผ๋‹ˆ๊นŒ ์—†์–ด๋„ ๋  ๊ฒƒ ๊ฐ™์•„!! ๐Ÿค—๐Ÿค—

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if๋ฌธ์œผ๋กœ ์ผ€์ด์Šค ๋‚˜๋ˆ  ์ค€๊ฑฐ ๋„˜ ์ข‹๋‹ค ์Šจ๋ฐฐ..!
๋‚˜๋Š” ๋ฐฉ๊ธˆ ๋ฆฌํŽ™ํ„ฐ๋ง ํ•˜๋ฉด์„œ extension ํŒŒ์ผ์œผ๋กœ ๋”ฐ๋กœ ๋นผ์ฃผ๊ณ  ํ•ด๋ดค๋Š”๋ฐ,, ๊ทธ๋ ‡๊ฒŒ ํ•˜๋‹ˆ๊นŒ ๋„˜ ํŽธํ•˜๋“œ๋ž‘..!
์•„๋ž˜ ์ฒ˜๋Ÿผ ์š”๋กœ์ฝ”๋กฌ extension ๋นผ์ฃผ๊ณ 

extension UIViewController {

    func makeAlert(title : String,
                   message : String,
                   okAction : ((UIAlertAction) -> Void)? = nil,
                   completion : (() -> ())? = nil)
    {
        let alertViewController = UIAlertController(title: title, message: message,
                                                    preferredStyle: .alert)
        
        let okAction = UIAlertAction(title: "ํ™•์ธ", style: .default, handler: okAction)
        alertViewController.addAction(okAction)
        
        self.present(alertViewController, animated: true, completion: completion)
    }
}

์‚ฌ์šฉํ•˜๋Š” ๋ถ€๋ถ„์—์„œ ์š”๋กœ์ฝ”๋กฌ okAction์— ์„ฑ๊ณต์ธ ๊ฒฝ์šฐ, ์‹คํŒจ์ธ ๊ฒฝ์šฐ ๋‚˜๋ˆ ์คฌ์—‰!

//์„ฑ๊ณต์ธ ๊ฒฝ์šฐ
self.makeAlert(title: "๋กœ๊ทธ์ธ", message: response.message, okAction: { _ in
                        guard let welcomeVC = self.storyboard?.instantiateViewController(withIdentifier: "WelcomeVC") as? WelcomeVC else {return}
                        welcomeVC.modalPresentationStyle = .fullScreen
                        self.present(welcomeVC, animated: true, completion: nil)
 })

//์‹คํŒจ์ธ ๊ฒฝ์šฐ
self.makeAlert(title: "๋กœ๊ทธ์ธ", message: response.message, okAction: { _ in
                    setTextFieldEmpty() //์š”๊ฑด ์‹คํŒจํ–ˆ์„๋•Œ textfield๋ฅผ ๋น„์›Œ์ฃผ๊ณ ์‹ถ์–ด์„œ ๋‚ด๊ฐ€ ์ง  ํ•จ์ˆ˜..!
 })

if let userData = response.data {
self.showAlert(title: "๋กœ๊ทธ์ธ", message: response.message)
}
UserDefaults.standard.set(nameTextField.text, forKey: "userName")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ’ก ์ง€์€์˜ ํŒ
UserDefaults์˜ key๋ฅผ ์ฝ”๋“œ ๋‚ด์—์„œ ์ง์ ‘ ์„ค์ •ํ•ด ์ค„ ๊ฒฝ์šฐ, ๋‚˜์ค‘์— ๋‚ด๊ฐ€ ๋น„์Šทํ•œ ๊ฒฝ์šฐ์— ์‚ฌ์šฉํ•˜๋ ค๊ณ  ์ €์žฅํ•ด๋‘” key value๊ฐ€ ์žˆ์„ํ…๋ฐ.. ํ•˜๊ณ  ์ฐพ์•„๋‹ค๋‹ˆ๋Š” ์ผ์ด ๋ฐœ์ƒํ•˜๊ฒŒ ๋ผ..! ์—„์ฒญ ํ—ท๊ฐˆ๋ฆฌ๊ตฌ.. (์ด๊ฑด ๋‚ด ๊ฒฝํ—˜๋‹ด..!)
์ง€๊ธˆ ๊ฐ™์€ ๊ฒฝ์šฐ๋„ 1. ๋กœ๊ทธ์ธ ์„ฑ๊ณต์‹œ 2. ํšŒ์›๊ฐ€์ž… ์„ฑ๊ณต์‹œ 3. ๋กœ๊ทธ์ธ/ํšŒ์›๊ฐ€์ž… ํ™•์ธ๋ทฐ์—์„œ ๋™์ผํ•œ ํ‚ค๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์ง€! ์ด ์ž‘์—…๋“ค์˜ ๊ฐœ์ˆ˜๊ฐ€ ๋Š˜์–ด๋‚˜๊ฒŒ ๋˜๋ฉด ์ผ์ผ์ด ๊ด€๋ฆฌํ•ด์ฃผ๊ณ  ์ฐพ์•„๋‹ค๋‹ˆ๋Š”๊ฒŒ ์–ด๋ ค์›Œ์ง€๊ฒŒ ๋ ๊ฑฐ์•ผ

๊ทธ๋ž˜์„œ Extension์œผ๋กœ Userdefaults์˜ key๊ฐ’๋“ค์„ ๋นผ์„œ ๊ด€๋ฆฌํ•˜๋Š” ๊ฑธ ์ถ”์ฒœํ•ด!!

extension UserDefaults {
    // UserDefaults key value๊ฐ€ ๋งŽ์•„์ง€๋ฉด ๊ด€๋ฆฌํ•˜๊ธฐ ์–ด๋ ค์›Œ์ง€๋ฏ€๋กœ enum 'Keys'๋กœ ๋ฌถ์–ด ๊ด€๋ฆฌ
    enum Keys {
        static var loginUserName = "loginUserName"
    }
}

Comment on lines 49 to 64
func showAlert(title: String, message: String, okAction: ((UIAlertAction) -> Void)? = nil) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let okAction = UIAlertAction(title: "ํ™•์ธ", style: .default, handler: { action in
/// ์„œ๋ฒ„์—์„œ ๋ฐ›์€ message๊ฐ€ "ํšŒ์› ๊ฐ€์ž… ์„ฑ๊ณต"์ผ ๋•Œ๋งŒ ํ™”๋ฉด ์ „ํ™˜
if message == "ํšŒ์› ๊ฐ€์ž… ์„ฑ๊ณต" {
/// present ํ™”๋ฉด ์ „ํ™˜
/// Main ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ SignupVC -> Main ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ SuccessVC
guard let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "SuccessVC") as? SuccessVC else {return}
nextVC.message = self.nameTextField.text
nextVC.modalPresentationStyle = .fullScreen
self.present(nextVC, animated: true, completion: nil)
}
})
alert.addAction(okAction)
present(alert, animated: true)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ๋ถ€๋ถ„์„ extension์œผ๋กœ ๋นผ์„œ ๊ตฌํ˜„ํ•ด๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š” ๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž… ๋‘˜ ๋‹ค์—์„œ ์“ฐ์ด๋‹ˆ๊นŒ!! ๐Ÿ‘๐Ÿป

Copy link
Member

@hyun99999 hyun99999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค! ํ’€๋ฆฌํ€˜์˜ ํ™”๋ฉด์ „ํ™˜์„ ์„ค๋ช…ํ•ด์ฃผ์‹ ๊ฒŒ ๋„ˆ๋ฌด ์ธ์ƒ์ ์ด๋„ค์š” ? ^^

Comment on lines 68 to 73
private func isInvalidLoginData(data: Data) -> NetworkResult<Any> {
let decoder = JSONDecoder()
guard let decodedData = try? decoder.decode(LoginDataModel.self, from: data) else {return .networkFail}
return .pathErr(decodedData)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

networkFail ๋ณด๋‹ค๋Š” ๋””์ฝ”๋”ฉ์„ ์‹คํŒจํ•œ๋‹ค=์ž˜๋ชป๋œ๊ฒฝ๋กœ๋กœ ์š”์ฒญํ•ด์„œ ๋ฐ์ดํ„ฐ๊ฐ€ ๋„˜์–ด์˜ค์ง€ ์•Š์•˜๋‹ค.or ๋ฐ์ดํ„ฐ๊ฐ€ ํ˜•์‹์ด ๋งž์ง€ ์•Š๋Š”๋‹ค
์ด๊ธฐ ๋•Œ๋ฌธ์— .pathErr ๊ฐ€ ์–ด์šธ๋ฆฌ๋Š”๊ฑฐ ๊ฐ™์•„์š”!
๊ทธ๋ฆฌ๊ณ  .pathErr ๋Š” requestErr ๋กœ ๋ฐ”๊ฟ”์„œ ๊ฒฝ๋กœ๋Š” ๋งž์ง€๋งŒ ์š”์ฒญ์— ๋Œ€ํ•œ ์—๋Ÿฌ๋ฅผ ๋‹ค๋ฃฐ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋ฉด ์ข‹์„๊ฑฐ ๊ฐ™์•„์š”!
์ œ ์ฝ”๋ฆฌ๋ฅผ ๋ณด์…จ๋‹ค๋‹ˆ๊นŒ.. ๋„ต.. ์š”๊ธฐ๊นŒ์ง€๋งŒ ๋‚จ๊ธฐ๊ฒ ์Šต๋‹ˆ๋‹น~

Comment on lines +84 to +92
@IBAction func touchUpProfileButton(_ sender: Any) {
/// present ํ™”๋ฉด ์ „ํ™˜
/// YoutubeMain ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ HomeVC -> Main ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ navigationController
let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
guard let navi = storyboard.instantiateViewController(withIdentifier: "MainNavi") as? UINavigationController else {return}

navi.modalPresentationStyle = .fullScreen
present(navi, animated: true, completion: nil)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ข‹์€ ๋ฐฉ๋ฒ•์ด๋„ค์š”..! ๐Ÿ‘

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ˆ˜๋นˆ์„ ๋ฐฐ ๋•๋ถ„์—... ๋‚œ ๊ตฌ์›๋ฐ›์•—์–ด...
์ด๋ฐฉ๋ฒ•๋„ ์ข‹์€๋ฐ ํ˜„๊ทœ์Šจ๋ฐฐ๊ป˜์„œ Scene Delegate์—์„œ RootView ์„ค์ •์ด๋ž‘, NavigationController ์„ค์ •ํ•ด์ฃผ๊ณ  ์Šค๋ณด ์—†์ด ์ฝ”๋“œ๋กœ ์งœ๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๋Œ€์œ ,,, ์ •ํ™•ํžˆ๋Š” ์ž˜ ๋ชจ๋ฅด์ง€๋งŒ ๊ทธ๋Ÿฐ ๋ฐฉ๋ฒ•์ด ์žˆ๋Œ€์œ ,,, ํ•˜์ง€๋งŒ ๋‚œ ๋ชจ๋Œ€.

Copy link
Member

@hellozo0 hellozo0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ˆ˜๋นˆ์–‘.... ๊ทธ๋ฆผ๊นŒ์ง€ ๊ทธ๋ ค์ฃผ๊ณ  ๋„˜ ์นœ์ ˆํ•œ๊ฑฐ ์•„์ž‰๊ต..?
์ˆ˜๋นˆ์–‘์˜ ์ฝ”๋“œ๋ฅผ ๋ณด๊ณ  ๋„˜ ๋งŽ์ด ๋ฐฐ์šด๋‹ค... ๋‚˜ ์—ฌํƒœ ์„ธ๋ฏธ๋‚˜ ํ•˜๋ฉด์„œ ๊ถ๊ธˆํ–ˆ๋˜ NavigationController์— VC์•ˆ ๋งŒ๋“ค๊ณ  ์—ฐ๊ฒฐํ•˜๋Š”๊ฑธ ์ˆ˜๋นˆ์–‘ ๋•์— ํ•œ๋‹ฌ๋งŒ์— ๊นจ๋‹ฌ์•˜์–ด... ๋‹น์‹ ์€ ๋‚˜์˜ ์€์ธ์ด์˜ค,,,
์„œ๋ฒ„ ์งˆ๋ฌธ๊นŒ์ง€ ๋ฐ›์•„์ค˜์„œ ๊ณ ๋งˆ์›ก!!!!!!!

Comment on lines +84 to +92
@IBAction func touchUpProfileButton(_ sender: Any) {
/// present ํ™”๋ฉด ์ „ํ™˜
/// YoutubeMain ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ HomeVC -> Main ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ navigationController
let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
guard let navi = storyboard.instantiateViewController(withIdentifier: "MainNavi") as? UINavigationController else {return}

navi.modalPresentationStyle = .fullScreen
present(navi, animated: true, completion: nil)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ˆ˜๋นˆ์„ ๋ฐฐ ๋•๋ถ„์—... ๋‚œ ๊ตฌ์›๋ฐ›์•—์–ด...
์ด๋ฐฉ๋ฒ•๋„ ์ข‹์€๋ฐ ํ˜„๊ทœ์Šจ๋ฐฐ๊ป˜์„œ Scene Delegate์—์„œ RootView ์„ค์ •์ด๋ž‘, NavigationController ์„ค์ •ํ•ด์ฃผ๊ณ  ์Šค๋ณด ์—†์ด ์ฝ”๋“œ๋กœ ์งœ๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๋Œ€์œ ,,, ์ •ํ™•ํžˆ๋Š” ์ž˜ ๋ชจ๋ฅด์ง€๋งŒ ๊ทธ๋Ÿฐ ๋ฐฉ๋ฒ•์ด ์žˆ๋Œ€์œ ,,, ํ•˜์ง€๋งŒ ๋‚œ ๋ชจ๋Œ€.

/// Main ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ LoginVC -> Main ์Šคํ† ๋ฆฌ๋ณด๋“œ์˜ SuccessVC
guard let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "SuccessVC") as? SuccessVC else {return}

nextVC.message = self.nameTextField.text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if๋ฌธ์œผ๋กœ ์ผ€์ด์Šค ๋‚˜๋ˆ  ์ค€๊ฑฐ ๋„˜ ์ข‹๋‹ค ์Šจ๋ฐฐ..!
๋‚˜๋Š” ๋ฐฉ๊ธˆ ๋ฆฌํŽ™ํ„ฐ๋ง ํ•˜๋ฉด์„œ extension ํŒŒ์ผ์œผ๋กœ ๋”ฐ๋กœ ๋นผ์ฃผ๊ณ  ํ•ด๋ดค๋Š”๋ฐ,, ๊ทธ๋ ‡๊ฒŒ ํ•˜๋‹ˆ๊นŒ ๋„˜ ํŽธํ•˜๋“œ๋ž‘..!
์•„๋ž˜ ์ฒ˜๋Ÿผ ์š”๋กœ์ฝ”๋กฌ extension ๋นผ์ฃผ๊ณ 

extension UIViewController {

    func makeAlert(title : String,
                   message : String,
                   okAction : ((UIAlertAction) -> Void)? = nil,
                   completion : (() -> ())? = nil)
    {
        let alertViewController = UIAlertController(title: title, message: message,
                                                    preferredStyle: .alert)
        
        let okAction = UIAlertAction(title: "ํ™•์ธ", style: .default, handler: okAction)
        alertViewController.addAction(okAction)
        
        self.present(alertViewController, animated: true, completion: completion)
    }
}

์‚ฌ์šฉํ•˜๋Š” ๋ถ€๋ถ„์—์„œ ์š”๋กœ์ฝ”๋กฌ okAction์— ์„ฑ๊ณต์ธ ๊ฒฝ์šฐ, ์‹คํŒจ์ธ ๊ฒฝ์šฐ ๋‚˜๋ˆ ์คฌ์—‰!

//์„ฑ๊ณต์ธ ๊ฒฝ์šฐ
self.makeAlert(title: "๋กœ๊ทธ์ธ", message: response.message, okAction: { _ in
                        guard let welcomeVC = self.storyboard?.instantiateViewController(withIdentifier: "WelcomeVC") as? WelcomeVC else {return}
                        welcomeVC.modalPresentationStyle = .fullScreen
                        self.present(welcomeVC, animated: true, completion: nil)
 })

//์‹คํŒจ์ธ ๊ฒฝ์šฐ
self.makeAlert(title: "๋กœ๊ทธ์ธ", message: response.message, okAction: { _ in
                    setTextFieldEmpty() //์š”๊ฑด ์‹คํŒจํ–ˆ์„๋•Œ textfield๋ฅผ ๋น„์›Œ์ฃผ๊ณ ์‹ถ์–ด์„œ ๋‚ด๊ฐ€ ์ง  ํ•จ์ˆ˜..!
 })

@yangsubinn yangsubinn merged commit 2c4a0b2 into main Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] iOS 4์ฐจ ๊ณผ์ œ
4 participants