Skip to content

김주희) 해리포터 과제#7

Open
coduhee wants to merge 25 commits into
mainfrom
juhee
Open

김주희) 해리포터 과제#7
coduhee wants to merge 25 commits into
mainfrom
juhee

Conversation

@coduhee

@coduhee coduhee commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator

일단 굴러가기는 하게 작성한 코드입니다..
리뷰 남겨주시면 정말정말 감사하겠습니다..😊


// MARK: - JSON Data Loading
func loadBooks() {
dataService.loadBooks { [weak self] result in

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

weak 안써도 됨. 왜 일까요~?

Comment on lines +331 to +333
chapterStackView.addArrangedSubview(chapterLabel)
chapterStackView.subviews.forEach{ $0.removeFromSuperview() }
chapterStackView.addArrangedSubview(chapterLabel)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

chapterLabel이 2️⃣개

Comment on lines +231 to +233
seriesButtonStackView.snp.makeConstraints {
$0.leading.greaterThanOrEqualToSuperview().inset(20)
$0.trailing.lessThanOrEqualToSuperview().inset(20)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

좋은 방법이네요

Comment on lines +22 to +26
do { // (2번 안전장치) 파일 읽고 JSON 파싱
let data = try Data(contentsOf: URL(fileURLWithPath: path)) // 파일 내용을 메모리로 읽어옴
let bookResponse = try JSONDecoder().decode(BookResponse.self, from: data) // JSON을 Swift구조체(bookResponse)로 변환
let books = bookResponse.data.map { $0.attributes } // bookResponse.data는 배열이고 우리가 쓰고싶은건 attributes임
completion(.success(books)) // 성공

@yy-ss99 yy-ss99 Jan 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

제시된 코드 그대로 사용해서 구체적으로는 어떤 방식으로 진행되는지 몰랐는데 주희님 주석 덕분에 알고갑니다!

@coduhee coduhee changed the title 김주희) LV.5 까지 구현했습니다. 김주희) 해리포터 과제 Feb 2, 2026
Removed section about Service (DataService.swift) from README.
Added additional explanations and code snippets for ViewController and data flow in README.
Comment on lines +42 to +46
// 현재 보여줄 책 데이터 반환
var currentBook: Book? {
guard books.indices.contains(index) else { return nil } // index가 books 안에 진짜 존재할 때만 실행
return books[index]
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

연산 프로퍼티로 currentBook을 정의해서 사용할 수도 있군요.. 저는 이 부분 고민하다가 아키텍처 구조 자체를 바꿔버렸었는데 이런 방법이 있었네요!! 참고하고 갑니다😂

let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
if let date = formatter.date(from: dateString) { // 문자열을 date형식으로 변환
formatter.dateStyle = .long // 출력용 날짜 스타일

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

.long 스타일을 사용하면 '2 Februrary 2026' 형태로 출력되는 것 같습니다!
문제에서는 'Februrary 2, 2026' 형태로 출력하라고 요구하고 있어서 형식만 수정해주시면 좋을 것 같아요!

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.

5 participants