-
Notifications
You must be signed in to change notification settings - Fork 4
[STEP 2] 씨유, 도도 #13
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
base: 1_cu
Are you sure you want to change the base?
[STEP 2] 씨유, 도도 #13
Changes from 17 commits
bd1ad6c
82716e6
63cc308
96417b0
189eee5
098c024
6d66b91
23fb45d
81c8635
5ac2e7b
74f8786
18c5de7
4b2be29
cc6d640
5be5bf9
575d971
bf9575e
ba6a92a
5864854
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // | ||
| // ItemTableViewCell.swift | ||
| // Expo1900 | ||
| // | ||
| // Created by 박도원 on 2022/09/30. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| class ItemTableViewCell: UITableViewCell { | ||
|
|
||
| @IBOutlet weak var itemImageView: UIImageView! | ||
| @IBOutlet weak var itemNameLabel: UILabel! | ||
| @IBOutlet weak var shortDescriptionLabel: UILabel! | ||
| var itemInfo: Item? | ||
|
|
||
| override func awakeFromNib() { | ||
| super.awakeFromNib() | ||
| } | ||
|
|
||
| override func setSelected(_ selected: Bool, animated: Bool) { | ||
|
||
| super.setSelected(selected, animated: animated) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // | ||
| // Expo1900 - ViewController.swift | ||
| // Created by yagom. | ||
| // Copyright © yagom academy. All rights reserved. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| class ExpositionViewController: UIViewController { | ||
| @IBOutlet weak var titleLabel: UILabel! | ||
|
||
| @IBOutlet weak var visitorsLabel: UILabel! | ||
| @IBOutlet weak var locationLabel: UILabel! | ||
| @IBOutlet weak var durationLabel: UILabel! | ||
| @IBOutlet weak var descriptionLabel: UILabel! | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| guard let expositionData = try? JSONParser().getExpositionData() else { | ||
| return | ||
| } | ||
|
|
||
| setUiData(from: expositionData) | ||
| } | ||
|
|
||
| func setUiData(from data: Exposition) { | ||
|
||
| titleLabel.text = data.title | ||
| visitorsLabel.text = "방문객 : \(numberFormatToDecimal(of: data.visitors)) 명" | ||
|
||
| locationLabel.text = "개최지 : \(data.location)" | ||
| durationLabel.text = "개최 기간 : \(data.duration)" | ||
| descriptionLabel.text = data.description | ||
| } | ||
|
|
||
| func numberFormatToDecimal(of number: Int?) -> String { | ||
| let numberFormatter = NumberFormatter() | ||
| numberFormatter.numberStyle = .decimal | ||
|
|
||
| guard let newNumber = number, let result = numberFormatter.string(from: NSNumber(value: newNumber)) else { | ||
| return "NaN" | ||
|
||
| } | ||
|
|
||
| return result | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // | ||
| // ItemInfoViewController.swift | ||
| // Expo1900 | ||
| // | ||
| // Created by 박도원 on 2022/10/05. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| class ItemInfoViewController: UIViewController { | ||
| var itemInfo: Item? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 어디는 아웃렛변수가 위에있고 여기는 아웃렛변수가 프로퍼티 아래에 있네요!!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아웃렛 변수 전부 상단으로 통일해보겠습니다! |
||
| @IBOutlet weak var itemImageView: UIImageView! | ||
|
||
| @IBOutlet weak var itemDescriptionLabel: UILabel! | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super와 함수호출 사이에 한번 개행해주면 좋습니다!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵! |
||
| setItemData() | ||
| } | ||
|
|
||
| func setItemData() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 외부에서 접근하지 않는다면 은닉화 해주세요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 |
||
| guard let data = itemInfo else { | ||
| return | ||
| } | ||
| itemImageView.image = UIImage(named: data.image) | ||
| itemDescriptionLabel.text = data.description | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // | ||
| // ItemsTableViewController.swift | ||
| // Expo1900 | ||
| // | ||
| // Created by 박도원 on 2022/10/04. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| class ItemsTableViewController: UIViewController { | ||
| @IBOutlet weak var itemTableView: UITableView! | ||
|
||
| var itemList: [Item] = [] | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
| guard let items: [Item] = try? JSONParser().getItemsData() else { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 생명주기 내부에 바로 작성하기보다는 이 기능을 하는 메서드를 만들어서 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 |
||
| return | ||
| } | ||
| itemList = items | ||
|
|
||
| itemTableView.delegate = self | ||
|
||
| itemTableView.dataSource = self | ||
| } | ||
| } | ||
|
|
||
| extension ItemsTableViewController: UITableViewDelegate, UITableViewDataSource { | ||
|
||
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| return itemList.count | ||
| } | ||
|
|
||
| func setCellData(cell: ItemTableViewCell, data: Item) -> ItemTableViewCell { | ||
|
||
| cell.itemInfo = data | ||
| cell.itemNameLabel.text = data.name | ||
| cell.itemImageView.image = UIImage(named: data.image) | ||
| cell.shortDescriptionLabel.text = data.shortDescription | ||
| return cell | ||
| } | ||
|
|
||
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| guard var cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? ItemTableViewCell else { | ||
|
||
| return UITableViewCell() | ||
| } | ||
| cell = setCellData(cell: cell, data: itemList[indexPath.row]) | ||
| return cell | ||
| } | ||
|
|
||
| func numberOfSections(in tableView: UITableView) -> Int { | ||
|
||
| return 1 | ||
| } | ||
|
|
||
| func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
|
||
| let cell = tableView.cellForRow(at: indexPath) as? ItemTableViewCell | ||
| guard let itemInfoVC = self.storyboard?.instantiateViewController(withIdentifier: "ItemInfoVC") as? ItemInfoViewController else { | ||
| return | ||
| } | ||
| itemInfoVC.itemInfo = cell?.itemInfo | ||
| navigationController?.pushViewController(itemInfoVC, animated: true) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // | ||
| // SecondViewController.swift | ||
| // Expo1900 | ||
| // | ||
| // Created by 박도원 on 2022/09/29. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| class SecondViewController: UIViewController { | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| // Do any additional setup after loading the view. | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| // MARK: - Navigation | ||
|
|
||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
| // Get the new view controller using segue.destination. | ||
| // Pass the selected object to the new view controller. | ||
| } | ||
| */ | ||
|
|
||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // | ||
| // ExpositionError.swift | ||
| // Expo1900 | ||
| // | ||
| // Created by Schro on 2022/09/27. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum ParsingError: Error, LocalizedError { | ||
|
||
| case expositionParsingError, itemParsingError | ||
| var errorDescription: String { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 케이스와 프로퍼티 사이에 한번 개행해주면 더 읽기 편할거같아요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 |
||
| switch self { | ||
| case .expositionParsingError: | ||
| return "ExpositionParsing 실패" | ||
| case .itemParsingError: | ||
| return "ItemParsing 실패" | ||
| } | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // | ||
| // JSONParser.swift | ||
| // Expo1900 | ||
| // | ||
| // Created by 박도원 on 2022/10/04. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| class JSONParser { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VC에 직접적으로 파싱하지 않고 객체를 통해 파싱을 구현한 부분에 대해서 매우 칭찬합니다!! 👏 이번 스텝에서는 JSON 데이터를 화면에 잘 표시하는 것이 목적이기때문에 지금 방법도 너무 좋아요 👍
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 한번 제네릭으로 구현해보려고 시도했으나 아직 부족한 점이 있는 것 같습니다.. |
||
| func getExpositionData() throws -> Exposition { | ||
| guard let expositionDataAsset = NSDataAsset(name: "exposition_universelle_1900") else { | ||
|
||
| throw ParsingError.expositionParsingError | ||
| } | ||
| let expositionJsonDecoder = JSONDecoder() | ||
|
|
||
| guard let expositionData = try? expositionJsonDecoder.decode(Exposition.self, from: expositionDataAsset.data) else{ | ||
| throw ParsingError.expositionParsingError | ||
| } | ||
| return expositionData | ||
| } | ||
|
|
||
| func getItemsData() throws -> [Item] { | ||
| guard let itemDataAsset = NSDataAsset(name: "items") else { | ||
| throw ParsingError.itemParsingError | ||
| } | ||
| let itemJsonDecoder = JSONDecoder() | ||
|
|
||
| guard let itemData = try? itemJsonDecoder.decode([Item].self, from: itemDataAsset.data) else { | ||
| throw ParsingError.itemParsingError | ||
| } | ||
|
|
||
| return itemData | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "bangjja~universal@1x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "filename" : "bangjja~universal@2x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "filename" : "bangjja~universal@3x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "buddhism~universal@1x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "filename" : "buddhism~universal@2x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "filename" : "buddhism~universal@3x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "data" : [ | ||
| { | ||
| "filename" : "exposition_universelle_1900.json", | ||
| "idiom" : "universal" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "title":"파리 만국박람회 1900(L'Exposition de Paris 1900)", | ||
| "visitors":48130300, | ||
| "location":"프랑스 파리", | ||
| "duration":"1900. 04. 14 - 1900. 11. 12", | ||
| "description":"1900년 파리 만국박람회(지금의 세계 박람회[World’s Fair/Exposition/Expo])는 지난 세기를 기념하고 다음 세기를 향한 발전을 가속하자는 의미에서 1900년 4월 14일부터 11월 12일까지 프랑스 파리에서 열린 세계 박람회였다. 이 박람회에서 널리 선보였던 건축 양식이 바로 '아르누보'였다. 총 관람객수가 5000만 명에 달한 1900년 세계 박람회에서는 수많은 기계와 발명품, 그리고 건축물들이 전시됐는데 그 중에는 그랑드 루 드 파리 대관람차, 마트료시카 인형, 디젤 엔진, 유성영화, 에스컬레이터, 텔레그라폰 (최초의 자석식 녹음기) 등 지금도 널리 알려져 있는 것들도 등장했다.\n\n프랑스는 1855년에도 만국 박람회를 개최한 전력이 있었는데 전쟁 후 국가의 자부심과 신념을 다시 세우고자 하는 욕구로부터 비롯된 것이었다. 1900년 박람회가 성공을 거둔 것도 전후 국가 부흥이라는 똑같은 주제에 따른 것이었다. 1900년 파리 세계 박람회가 개최되기 8년 전인 1892년, 프랑스 정부는 새 세기의 도래를 환영하고 축하하는 박람회를 열 것이라고 발표했다.\n\n프랑스는 전세계 56개국에 초청장을 보냈고, 그 중 40개국이 수락하여 참가했다.참가국들이 이룬 것과 생활양식을 전시했다. 이 세계 박람회는 여러 가지 체험을 종합하여 익히도록 한 것이었다. 이를 통해 외국인들에게 각 국가들 간의 유사성은 물론 그 사이의 독특한 다양성을 깨닫도록 하는 기회를 제공했다. 또 새로운 문화를 경험하고 각국이 전시해 놓은 자국의 가치들을 전반적으로 더욱 이해할 수 있도록 했다. 이러한 상호 이해의 환경이 전쟁 시대 이후 필요하다고 여겨졌던 문화적 관용을 늘리는데 한몫하도록 했다. 박람회 개최 소식이 발표되자 독일에서 처음으로 열린 국제 박람회에 쏠렸던 관심은 풀리고 박람회 개최에 대한 호응이 어마어마하게 쏟아졌다. 박람회에 대한 지지도 대단해서 각국에서는 즉시 자국 전시관 계획을 세우기 시작했다. \n\n파리 만국박람회가 개최된 1900년 4월 14일부터 11월 12일까지 프랑스 파리에는 대한제국의 문화와 문물이 전시된 한국관이 세워졌습니다. 한국관은 경복궁의 근정전을 재현한 주전시관과 옛 국왕들의 위패를 모셔놓은 사당을 별채로 구성되었는데, 이는 우리 건축의 아름다움을 세계에 알린 첫 건축물이 되었습니다. 특히 만국박 람회의 대한제국관을 묘사한 프랑스 잡지 ‘르 프티 주르날(Le Petit Journal)’은 태극기를 표시해 당당하게 대한 제국의 상징으로 많은 관심을 받을 수 있었습니다.\n\n한국관의 전시품은 정확하게 어떤 것이 전시되었는지 알 수는 없지만 대한제국과 프랑스 정부간에 오고 간 문 서를 통해 짐작할 수 있습니다. 대한제국 정부는 우리의 다양한 전통문화를 나타내는 비단, 놋그릇, 도자기, 칠 보 등의 공예품을 제공한 것으로 보이며, 이 밖에도 악기, 옷, 가구, 예술품 등도 있었다고 합니다. 만국박람회는 참가한 나라들의 산업을 소개하는 역할을 했고, 전시는 물론 시상도 했는데 대한제국은 식물성 농업식품 분야 에서 그랑프리(대상)을 수상하였다고 합니다.\n\n1900년 11월 12일 파리 만국박람회가 폐막된 후 한국관에 출품되었던 전시품들은 다시 본국으로 돌아오지 못하고 대부분 현지에 기증되었는데, 이는 일종의 관례이기도 했지만 본국으로 회수하는데 드는 과도한 운송비용 때문이기도 했습니다.\n\n현재 이 전시품들은 프랑스에 있는 국립공예박물관, 국립예술직업전문학교, 국립음악원 음악박물관, 국립 기메 아시아박물관 등에 소장되어있습니다. 특히 전시품으로 기증된 악기들 중 해금은 현존하는 해금 가운데 가장 오래된 것으로 추정되고 있다고도 합니다. 우리의 소중한 역사적 유물을 멀리 두고 올 수 밖에 없던 상황이 안타깝게 느껴집니다.\n\n작고 힘없는 나라 대한제국이 세계 강국들이 모인 만국박람회에 참가한다는 자체가 불가능하다는 의견이 지배 적이었지만 1900년 프랑스 파리에 근정전을 본뜬 한국관이 우뚝 세워졌습니다. 그 존재만으로 독립된 나라임을 세계에 알리고자 했던 목표는 이루어진 것 같습니다. 그러나 안타깝게도 그로부터 5년 후인 1905년 을사늑약이 체결되었고, 대한제국은 독립국가로서 세계에서 점점 잊혀져 갔습니다." | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "flag~universal.pdf", | ||
| "idiom" : "universal" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awakeFromNib은 어떤 메서드인가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
객체가 생성 및 초기화를 모두 완료한 뒤에 호출되는 메서드라고 생각합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
커스텀 셀 파일을 만들 때 자동으로 생겨 필수적인 메서드인 줄 알았으나 삭제해도 문제가 없다는 걸 확인했습니다