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

πŸ•“ 4μ£Όμ°¨ 과제 #14

Merged
merged 8 commits into from
Aug 16, 2023
Merged

πŸ•“ 4μ£Όμ°¨ 과제 #14

merged 8 commits into from
Aug 16, 2023

Conversation

ena-isme
Copy link
Contributor

@ena-isme ena-isme commented Aug 14, 2023

4μ£Όμ°¨

4μ£Όμ°¨ κ³Όμ œμ—μ„œλŠ” κΈ°μ‘΄ Tving κ³Όμ œμ— Alamofire λ₯Ό μ΄μš©ν•˜μ—¬ μ˜ν™” API λ₯Ό μ—°κ²°ν•˜μ˜€μŠ΅λ‹ˆλ‹€.


μ£Όμš”μ½”λ“œ


λΆˆν•„μš”ν•œ λ°μ΄ν„°μ˜ λ³€μˆ˜λŠ” μž‘μ„±μ•Šκ³  Decoding ν•˜λ„λ‘ κ΅¬ν˜„ν•˜μ˜€μŠ΅λ‹ˆλ‹€.


import Foundation

struct MovieResponse: Codable {
    let results: [Results]
}

struct Results: Codable {
    let poster_path: String?
    let title: String
}

FirstCollectionView κ°€ 싀행될 λ•Œλ§ˆλ‹€ 데이터λ₯Ό λΏŒλ €μ£Όμ–΄μ•Ό ν•˜κΈ° λ•Œλ¬Έμ— FirstCollectionVIew 의 SuperVIew 인 HomeMainView 의 init μ—μ„œ getMovie() ν•¨μˆ˜λ₯Ό μ‹€ν–‰ν•˜μ˜€μŠ΅λ‹ˆλ‹€.


ViewWillAppear λ‚΄λΆ€μ—μ„œ getMovie() λ₯Ό μ‹€ν–‰μ‹œν‚¬ 수 μžˆμ§€λ§Œ ViewWillAppear λŠ” UIViewController μ—μ„œλ§Œ ν˜ΈμΆœν•  수 있기 λ•Œλ¬Έμ— init μ—μ„œ κ΅¬ν˜„ν•˜μ˜€μŠ΅λ‹ˆλ‹€.


override init(frame: CGRect) {
        super.init(frame: frame)

        getMovie()
}

private func getMovie() {
        MovieService.shared.getMovie() { response in
            switch response {
            case .success(let data):
                guard let data = data as? MovieResponse else { return }
                self.responseData = data.results
                self.firstCollectionView.reloadData()
            default:
                return
            }
        }
    }

μ‹€μŠ΅κ²°κ³Ό


Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-08-17.at.04.41.09.mp4

@ena-isme ena-isme merged commit b169152 into main Aug 16, 2023
@ena-isme ena-isme self-assigned this Aug 16, 2023
@HELLOHIDI HELLOHIDI self-requested a review August 21, 2023 05:45
Copy link

@HELLOHIDI HELLOHIDI left a comment

Choose a reason for hiding this comment

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

ν•œκΊΌλ²ˆμ— λ„ˆλ¬΄ λ§Žμ€ νŒŒμΌμ„ λ΄μ•Όλ˜μ„œ 둜직적인 리뷰보단 문법적, μ½”λ“œμ  μ€‘μ‹¬μœΌλ‘œ κ°„λ‹¨ν•˜κ²Œ 리뷰 λ‚¨κΉλ‹ˆλ‹€~ κ³ μƒν–ˆμ–΄μš”


$0.isScrollEnabled = true
$0.collectionViewLayout = layout
$0.frame = .init()

Choose a reason for hiding this comment

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

ν˜Ήμ‹œ μ—¬κΈ°μ„œ $0.frame = .init()을 ν•œ μ΄μœ λŠ” λ¬΄μ—‡μΈκ°€μš”?

$0.isScrollEnabled = true
$0.collectionViewLayout = layout
$0.frame = .init()
$0.translatesAutoresizingMaskIntoConstraints = false

Choose a reason for hiding this comment

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

$0.translatesAutoresizingMaskIntoConstraints = falseλ₯Ό μ™œ μΌλŠ”μ§€ μ•Œ 수 μžˆμ„κΉŒμš”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Snapkit 으둜 동적인 μ˜€ν† λ ˆμ΄μ•„μ›ƒμ„ 작기 μœ„ν•˜μ—¬ false 처리 ν•˜μ˜€μŠ΅λ‹ˆλ‹€!

}

func configureCell(_ results: Results){
imageURL = URL(string: "https://image.tmdb.org/t/p/original/" + (results.poster_path ?? "") ) ?? nil

Choose a reason for hiding this comment

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

baseURL은 μˆ¨κΈ°λŠ”κ²Œ μ’‹κ² μ Έ?

Choose a reason for hiding this comment

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

그리고 μ˜΅μ…”λ„ 처리λ₯Ό ν•˜λ©΄ λ”μš± λͺ…ν™•ν•œ λΆ„κΈ°μ²˜λ¦¬κ°€ κ°€λŠ₯ν•΄μ§ˆ κ±° κ°™μ•„μš”. λ§Œμ•½μ— imageURL에 nil값이 λ“€μ–΄κ°„λ‹€λ©΄ μ‚¬μš©μžμ€ μ–΄λ– ν•œ μ—λŸ¬ 메세지도 λͺ¨λ₯Έμ±„ 이미지가 λ‚˜μ˜€μ§€ μ•ŠλŠ” ν˜„μƒμ΄ 생기겠죠

Copy link
Contributor Author

Choose a reason for hiding this comment

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

μ•„ν•˜ ! μœ„μ—μ„œ 말고 이 κ³³μ—μ„œ λ°”λ‘œ 선언해쀄 κ±Έ κ·Έλž¬λ„€μš© κ°μ‚¬ν•©λ‹ˆλ‹€ :)

Comment on lines +29 to +33
self.backgroundColor = .white
self.addSubviews(cellView)
cellView.do {
$0.backgroundColor = .black
}

Choose a reason for hiding this comment

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

style을 μ§€μ •ν•˜λŠ” λ©”μ†Œλ“œ μ•ˆμ—μ„œ 계측ꡬ쑰에 κ΄€ν•œ 뢀뢄이 μžˆλŠ” μ΄μœ κ°€ 뭔지 μ•ŒκΉŒμš”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

어이쿠 ,, λ§˜λŒ€λ‘œ μ„ μ–Έν–ˆλ„€μš” ,,

fatalError("init(coder:) has not been implemented")
}

override var isSelected: Bool {

Choose a reason for hiding this comment

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

ν˜Ήμ‹œ μ™œ override ν‚€μ›Œλ“œλ₯Ό μ‚¬μš©ν–ˆλŠ”μ§€ μ•Œ 수 μžˆμ„κΉŒμš”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isSelected λΌλŠ” ν•¨μˆ˜κ°€ 이미 μ‘΄μž¬ν•˜λŠ” ν•¨μˆ˜κΈ° λ•Œλ¬Έμ— μž¬μ •μ˜ ν•˜κ³  μ‹Άμ–΄μ„œ override λ₯Ό μ‚¬μš©ν•˜μ˜€μŠ΅λ‹ˆλ‹€!

Comment on lines +54 to +56
private func target() {

}

Choose a reason for hiding this comment

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

μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” λ©”μ†Œλ“œλŠ” μ•ˆ μ“°λŠ”κ²Œ μ’‹κ²Ÿμ£ ?

$0.layer.cornerRadius = 3

adTextLabel.do {
let tvingImage = NSTextAttachment(image: UIImage(named: "tvNLogo") ?? UIImage())

Choose a reason for hiding this comment

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

NSTextAttachment 이건 μ²˜μŒλ΄μ„œ 그런데 ν˜Ήμ‹œ μ–΄λ–€ κ±΄κ°€μš”? κΆκΈˆν•˜λ„€μš”!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

라벨에 이미지와 λ¬Έμž₯을 같이 κ΅¬ν˜„ν•  수 μžˆλ„λ‘ 도와쀀닀고 ν•˜μ—¬ μ‚¬μš©ν•˜μ˜€λŠ”λ° ν˜Ήμ‹œ 더 쒋은 방식이 μžˆμ„κΉŒμš”?,,? (μ°Έκ³  μ‚¬μ΄νŠΈ : https://devddong.tistory.com/3 )


private init() {}

func getMovie(completion: @escaping(NetworkResult<Any>) -> Void) {

Choose a reason for hiding this comment

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

@escaping ν‚€μ›Œλ“œλ₯Ό μ™œ μ‚¬μš©ν•˜μ…¨λ‚˜μš”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@escaping 은 ν•¨μˆ˜ λ°–μ—μ„œ μ‹€ν–‰λ˜λŠ” ν΄λ‘œμ €κΈ° λ•Œλ¬Έμ— μ¦‰μ‹œ 싀행이 μ•„λ‹Œ λ„€νŠΈμ›Œν¬ μ—°κ²° 후에 λΉ„λ™κΈ°λ‘œ μ‹€ν–‰λ˜μ–΄μ•Ό ν•˜κΈ°μ— λΆ™μ—¬μ£Όμ—ˆμŠ΅λ‹ˆλ‹€ !

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.

2 participants