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/week4 API 연동하기 #7

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Feature/week4 API 연동하기 #7

wants to merge 14 commits into from

Conversation

HEHEEUN
Copy link
Collaborator

@HEHEEUN HEHEEUN commented Nov 8, 2024

API 연동하기

이슈

작업 내용

  • 4주차 실습 및 과제 API 연동하기.

Simulator

Simulator Screen Recording - iPhone 16 Pro - 2024-11-08 at 23 19 30

추가 구현 필요 부분

  • 다른 유저 취미 찾기 부분 구현 필요
  • 다음 과제는 커밋 잘못들어가 있는 거 .. 해결하기 ..

Copy link

@OneTen19 OneTen19 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 +93 to +100
do {
let logInResponse = try JSONDecoder().decode(LogInResponse.self, from: data)
let token = logInResponse.result.token
TokenManager.shared.saveToken(token)
completion(.success(logInResponse))
} catch {
completion(.failure(.unknownError))
}
Copy link

Choose a reason for hiding this comment

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

do-catch문 쓰신 거 좋네요!

}

let headers: HTTPHeaders = [
"Content-Type": "application/json",
Copy link

Choose a reason for hiding this comment

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

저는 그냥 ["token": "(token)"] 이렇게만 작성했는데 별 문제 없이 괜찮았어요!

Comment on lines +137 to +138
username: userNameTextField.text!, // optional처리
password: userPasswordTextField.text!
Copy link

Choose a reason for hiding this comment

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

강제 언래핑보다는 guard let으로 옵셔널 바인딩 처리해주거나
아니면 그냥 userNameTextField.text ?? "" 이런 식으로 기본 값 세팅해주는 게 더 안전할 것 같아요!

Copy link

Choose a reason for hiding this comment

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

오 토큰매니저 클래스를 따로 만드는 방법이 있었네요..

Copy link

@hooni0918 hooni0918 left a comment

Choose a reason for hiding this comment

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

노력하는 모습이멋져👍

@@ -6,7 +6,7 @@
//

import UIKit

//$0, $1, $2 ... - param을 축약

Choose a reason for hiding this comment

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

...? 이걸 왜 여기다?

Comment on lines +44 to +51
/// public let result: Result<Success, Failure>
/// Alamofire의 data response에는 result 프로퍼티가 존재하는데, 해당 프로퍼티는 Result<Success, Failure> 타입임!
/// 이 말은, 타입이 다른 함수에서 리턴되어 넘어갈 때, success로 넘어갈 수 있고 failure로 넘어갈 수 있다는 것
/// 그리고 그 안에는 우리가 원하는 결과값들이 존재한다.
/// Result<Bool, NetworkError> : 성공 시 Bool, 실패 시 NetworkError값을 return 하게 됨.
/// Success 하면 Bool 값을, Failure 하면 NetworkError를 리턴하겠다는 뜻
/// Success에는 원하는 타입이 올 수 있고, Failure에는 Error 프로토콜이 채택된 것이 리턴될 수 있도록 되어야 함
switch response.result {

Choose a reason for hiding this comment

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

배우고 기록하는 열정 👍


import UIKit

class LogInViewController: UIViewController { //hee eun

Choose a reason for hiding this comment

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

주석은 무슨의미인가요?

Copy link

@yurim830 yurim830 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!!


private func setLayout() {
// SnapKit을 통해 오토레이아웃 코드 변경하기.
NSLayoutConstraint.activate(

Choose a reason for hiding this comment

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

SnapKit import 하셨는데 �SnapKit으로 레이아웃을 설정하지 않으신 이유가 궁금합니다!

}
}

extension ChartViewController: UITableViewDelegate{}

Choose a reason for hiding this comment

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

작성한 코드가 없다면 delegate는 삭제해도 좋을 것 같습니다:D


import Foundation

class TokenManager {

Choose a reason for hiding this comment

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

오호 TokenManager로 토근을 관리하�셨군요!! 흥미롭습니다

let token = logInResponse.result.token
TokenManager.shared.saveToken(token)
completion(.success(logInResponse))
} catch {

Choose a reason for hiding this comment

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

잘 몰라서 그러는데, .success 케이스 안에서도 에러가 발생하는 경우가 있나요? 있다면 어떤 경우인지 궁금합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants