-
Notifications
You must be signed in to change notification settings - Fork 4
[STEP 2] rookie, uno, poodle #14
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_poodle
Are you sure you want to change the base?
Changes from all commits
ddafbe0
f00e5d5
3e0a784
05e3a9a
b4a1098
3ee8d03
8276c54
2434177
9abba97
7529295
ca0aee6
cca3097
0889686
40bf7ff
de8ab8a
eca9370
2af4239
aa09f73
6581ee8
ee7f432
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // | ||
| // ExhibitionViewController.swift | ||
| // Expo1900 | ||
| // | ||
| // Created by 임채윤 on 2022/10/04. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| class ExhibitionViewController: UIViewController { | ||
| @IBOutlet weak var workPieceItemTableView: UITableView! | ||
| @IBOutlet weak var navigationBarItem: UINavigationItem! | ||
|
|
||
| var workPieceInformationData = [WorkPieceInformation]() | ||
|
|
||
| let cellName = "workPieceItemCell" | ||
|
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. cell identifier를 상수로 저장한 부분 너무 좋습니다 👍 |
||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
| workPieceInformationJsonParsingData() | ||
| workPieceItemTableView.delegate = self | ||
| workPieceItemTableView.dataSource = self | ||
| } | ||
|
|
||
| func workPieceInformationJsonParsingData() { | ||
|
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. Main VC에서 언급했던 내용처럼 파싱 모델을 만들어서 구현해보면 좋을 거같아요! |
||
| let jsonDecoder = JSONDecoder() | ||
| guard let dataAsset = NSDataAsset(name: "items"), | ||
| let data = try? jsonDecoder.decode([WorkPieceInformation].self, from: dataAsset.data) else { return } | ||
|
|
||
| workPieceInformationData = data | ||
| } | ||
|
|
||
| override func viewWillAppear(_ animated: Bool) { | ||
|
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. viewDidLoad 메서드와 다른 위치에 있군요! |
||
| navigationBarItem.title = "한국의 출품작" | ||
| self.navigationController?.navigationBar.isHidden = false | ||
| } | ||
|
|
||
| override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
| if segue.identifier == "workPieceItemDetail" { | ||
|
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. segue의 identifier를 통해 데이터를 전달했군요! 지금 방식도 틀리지는 않습니다 !! 😀 |
||
| if let destination = segue.destination as? WorkPieceItemViewController { | ||
| if let selectedIndex = self.workPieceItemTableView.indexPathForSelectedRow?.row { | ||
| destination.prepareImage = workPieceInformationData[selectedIndex].imageName | ||
| destination.prepareDescriptionLabel = workPieceInformationData[selectedIndex].description | ||
| destination.prepareTitleName = workPieceInformationData[selectedIndex].name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| extension ExhibitionViewController: UITableViewDataSource, UITableViewDelegate { | ||
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| return workPieceInformationData.count | ||
| } | ||
|
|
||
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| guard let workPieceItemCell = workPieceItemTableView.dequeueReusableCell(withIdentifier: cellName, for: indexPath) as? WorkPieceItemTableViewCell else { return UITableViewCell() } | ||
|
|
||
| workPieceItemCell.workPieceItemImageView.image = UIImage(named: workPieceInformationData[indexPath.row].imageName) | ||
|
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. 커스텀 셀 타입에서 메서드를 통해 조금 더 간결하게 표현해보세요!! 💪 |
||
| workPieceItemCell.workPieceItemTitleLabel.text = workPieceInformationData[indexPath.row].name | ||
| workPieceItemCell.workPieceItemDescriptionLabel.text = workPieceInformationData[indexPath.row].shortDescription | ||
|
|
||
| return workPieceItemCell | ||
| } | ||
| } | ||
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.
파일위치를 수정하면 좋을 거같아요! 커스텀 셀과 앱,씬 딜리게이트, 뷰컨트롤러들끼리 섞여있군요!