SSUMC-6th / iOS_A

SSUMC 6๊ธฐ iOS ์Šคํ„ฐ๋”” A์กฐ
0 stars 0 forks source link

[baki/week10] Network(2) #75

Closed heemings closed 2 months ago

heemings commented 2 months ago

๐Ÿ“Summary

๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž…, ์ž๋™๋กœ๊ทธ์ธ ๊ตฌํ˜„

๐Ÿ’กPR Point

func loginAPI(id: String, password: String, completion: @escaping (Bool) -> Void) {
        provider.request(.login(id: id, password: password)) { result in
            DispatchQueue.main.async {
                switch result {
                case let .success(response):
                    if let tokenResponse = try? response.map(TokenResponse.self) {
                        TokenManager.shared.accessToken = tokenResponse.access_token
                        TokenManager.shared.refreshToken = tokenResponse.refresh_token
                        completion(true)
                    } else {
                        completion(false)
                    }
                case .failure:
                    completion(false)
                }
            }
        }
    }

์ด ๋ถ€๋ถ„์ด ๊ฐ€์žฅ ์–ด๋ ต๊ฒŒ ๋Š๊ปด์กŒ๋Š”๋ฐ ์ฐจ๋ก€๋Œ€๋กœ ๋”ฐ๋ผ๊ฐ€๋ฉด์„œ ๊ณต๋ถ€ํ•ด๋ณด๋‹ˆ ๋กœ๊ทธ์ธ ๋กœ์ง์— ๋Œ€ํ•ด ์ดํ•ดํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค

๐Ÿค” Question

์ž‘์—…ํ•˜์‹œ๋ฉด์„œ ๊ถ๊ธˆํ–ˆ๋˜ ์งˆ๋ฌธ๋“ค์„ ๋‚จ๊ฒจ์ฃผ์„ธ์š”.

๐Ÿ”‘ย Simulator

Simulator Screen Recording - iPhone 15 Pro - 2024-07-03 at 19 22 08