# ๐ฐ๐ท๐ซ๐ท ๋ง๊ตญ๋ฐ๋ํ ๐บ๐ธ๐ฆ๐น
## ๋ชฉ์ฐจ
1. [์๊ฐ](#-์๊ฐ)
2. [ํ์](#-ํ์)
3. [ํ์๋ผ์ธ](#-ํ์๋ผ์ธ)
4. [UML](#-UML)
5. [์คํ ํ๋ฉด](#-์คํ-ํ๋ฉด)
6. [ํธ๋ฌ๋ธ ์ํ
](#-ํธ๋ฌ๋ธ-์ํ
)
7. [ํต์ฌ ๊ฒฝํ](#-ํ๋ก์ ํธ-์ํ-์ค-ํต์ฌ-๊ฒฝํ)
8. [์ฐธ๊ณ ๋งํฌ](#-์ฐธ๊ณ -๋งํฌ)
## 1. ์๊ฐ
- 1900๋
์ ํ๋์ค ํ๋ฆฌ์์ ์ด๋ฆฐ ๋ง๊ตญ๋ฐ๋ํ์ ๋ํ ์๊ฐ์, ํ๊ตญ์ ์ถํ์์ ๋ํด ์์๋ณผ ์ ์๋ ์ฑ์
๋๋ค.
<br>
## 2. ํ์
|Ayaan | bella |
| --- | --- |
|<img src= "https://i.imgur.com/Unq1bdd.png" width ="155"/>| <img src=https://user-images.githubusercontent.com/99257965/190572701-5e51fd28-455f-4c3b-924d-0baade5011a3.png width="155" height="155" > |
| [@oneStar92](https://github.com/oneStar92) | [@hyhy0429](https://github.com/hyhy0429) |
<br>
## 3. ํ์๋ผ์ธ
**[STEP-1]**
- 221018
- JSON ์ดํด์ ํ์ฉ
- Asset์ ์ด๋ฏธ์ง์ JSON ๋ฐ์ดํฐ ์ถ๊ฐ ํ, ํด๋น ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํ `ExpositionUniverselle` ํ์
๊ณผ `ExpositionUniverselleItem` ํ์
์ถ๊ฐ
- 221019
- `ExpositionUniverselleItem` ํ์
์ญํ์ ๋ง๊ฒ ๋ฆฌํฉํ ๋ง
**[STEP-2]**
- 221020
- Main(์ฒซ๋ฒ ์งธ) ํ๋ฉด UI ๊ตฌ์ฑ์์ ๊ตฌํ
- MainVC ๋ด๋ถ ํ์ ํ๋กํผํฐ์ ๋ฉ์๋ ๊ตฌํ
- `ExpositionItems` ๋๋ฒ ์งธ ํ๋ฉด UI ๊ตฌ์ฑ์์ ๊ตฌํ
- `ExpositionItemsVC` ๋ด๋ถ ํ์ ํ๋กํผํฐ์ ๋ฉ์๋ ๊ตฌํ
- `ExpositionItemDetail` ์ธ๋ฒ ์งธ ํ๋ฉด UI ๊ตฌ์ฑ์์ ๊ตฌํ
- 221021
- `ExpositionItemDetailVC` ๋ด๋ถ ํ์ ํ๋กํผํฐ์ ๋ฉ์๋ ๊ตฌํ
- ๊ฐ ํ๋ฉด์ ๋ง๋ `NavigationBar` ์ํ ๊ตฌํ
- `NameSpace` ๊ตฌํ
- `JSONProcessor` ๊ตฌํ
- MainVC ๋ฐ Detail ๋ด๋ถ TextView ์์ธ ์ค์
- 221025
- VC `final`, `super` ํค์๋ ์ฌ์ฉ
- `JSONProcessor`์ ๊ธฐ๋ฅ๋ถ๋ฆฌ์ ๋ค์ด๋ฐ ์์
- JASONParser ๋ด๋ถ fetchDataAsset ๋ฉ์๋ ์ถ๊ฐ
- ๋ถํ์ํ extension์ MARK ์ฃผ์์ผ๋ก ๋ณ๊ฒฝ
- MainVC์ ExpositionItemDetailVC ๋ด๋ถ์ TextView๋ฅผ Label๋ก ๋ณ๊ฒฝ
**[STEP-3]**
- 221026
- MainView ๋ด๋ถ ์คํ ๋ ์ด์์ ์์
- `ExpositionItemCell` ๊ตฌํ
- Dynamic Type์ ์ํ UILabel extension ๊ตฌํ
- 221027
- Main ํ๋ฉด ์๊ตฌ์ฌํญ์ ๋ง๋ Label ์คํ์ผ ๊ตฌํ
- MainVC `visitorLabel`์ ์ํ `DecimalNumberFormatter` ํ์ผ ์์ฑ๊ณผ ํ์
๊ตฌํ
- Label์ `Dynamic Type` ํด์ ๋๋ ๋ฒ๊ทธ ์์
- Main ํ๋ฉด ์ธ๋ก ๊ณ ์ ๊ตฌํ
- ๋ชจ๋ VC์์ override๋ฅผ ํตํ `supportedInterfaceOrientations` ํ๋กํผํฐ ๊ตฌํ
- 221028
- MVC ์ญํ ๋ถ๋ฐฐ๋ฅผ ์ํ `MainViewManager` ํ์
๊ตฌํ
<br>
## 4. UML
<img src="https://i.imgur.com/IFXc1gS.jpg" width="800" height="500"/>
## 5. ์คํํ๋ฉด
|์คํ ํ๋ฉด|๋ค์ด๋๋ฏน ํ์
|
|:---:|:---:|
|<img src="https://i.imgur.com/77SkGR0.gif" width="400" height="400"/>|<img src="https://i.imgur.com/gb03T08.gif" width="200" height="400"/>|
## 6. ํธ๋ฌ๋ธ ์ํ
#### DTO Type์ ํ๋กํผํฐ ์ ๊ทผ ์ ์ด์
- DTO์ ํ๋กํผํฐ์ ์ ๊ทผ ์ ์ด์๋ฅผ `private(set)`๊ณผ `let` ๋๊ฐ์ง ์ค์์ ๋ฌด์์ ์ฌ์ฉํด์ผ ํ ์ง ๊ณ ๋ฏผํ์ต๋๋ค.
- `private(set)`์ ๊ฒฝ์ฐ ๋ด๋ถ์์๋ ๋ณ๊ฒฝ์ด ๊ฐ๋ฅํ๋ `let`์ ๊ฒฝ์ฐ ์ด๋์
๋ผ์ด์ง ์ดํ ๋ด/์ธ๋ถ์์ ๋ณ๊ฒฝ์ด ๋ถ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์ DTO Type์ ํ๋กํผํฐ ์ ๊ทผ ์ ์ด์๋ `let`์ผ๋ก ์ ์ธํ๋ ๊ฒ์ด ๋ ์ฌ๋ฐ๋ฅด๋ค๊ณ ์๊ฐํด `let`์ ์ฌ์ฉํ์์ต๋๋ค.
#### Main ํ๋ฉด ๊ตฌ์ฑ์, TextView ์ฌ์ฉ vs label ์ฌ์ฉ
- ์ฒซ๋ฒ์งธ ํ๋ฉด์ธ Main ํ๋ฉด์์, ExpositionUniverselle DTO์ ์ฅ๋ฌธ์ text์ธ description์ ๊ตฌํํ๊ธฐ ์ํ UI ๊ตฌ์ฑ์์๋ฅผ ๊ตฌ์ฑํจ์ ์์ด์ `TextView`์ `Label` ์ฌ์ฉ์ ๋ํด์ ๊ณ ๋ฏผํ์ต๋๋ค.
`Apple HIG` ์ ๊ฐ ๋ฌธ์์ [Displaying Text Content in iOS](https://developer.apple.com/library/archive/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/UsingTextClasses/UsingTextClasses.html)๋ฅผ ์ฐธ๊ณ ํ์์ต๋๋ค. ํฌ๊ฒ `label`์ ์๋์ text๋ฅผ ๋ณด์ฌ์ฃผ๋ฉฐ ํธ์งํ ์ ์๋ ์ ๊ณผ, `TextView` ๋ ๋ค๋์ text๋ฅผ ๋ณด์ฌ์ฃผ๋ฉฐ ํธ์ง์ ์ ํ์ด ๊ฐ๋ฅํ๋ค๋ ์ ์ด ์์์ต๋๋ค.
๊ทธ๋ผ์๋ ๋ถ๊ตฌํ๊ณ , ์ ํฌ๋ ๋ค๋์ text๋ฅผ ๋ณด์ฌ์ฃผ๋ ๊ฒ์ ์ฐ์ ์์๋ก ์๊ฐํ์ฌ `TextView` ๋ฅผ ์ ํํ์ฌ ๊ตฌํํ์๋ค๊ฐ, ํ์ฌ ํ๋ก์ ํธ ์ํฉ๊ณผ ๋ฌ๋ฆฌ `editable` ๊ธฐ๋ฅ์ ํ์๋ก ํ ๋์ `TextView`๋ฅผ ์ฌ์ฉํด์ผ ํจ์ ๋ํด ์๊ฒ๋์๊ณ , `label`๋ก ๋ณ๊ฒฝํ๊ฒ ๋์์ต๋๋ค.
#### Segue๋ฅผ ํตํ ํ๋ฉด ์ ํ์ ๋ฐ์ดํฐ ์ ์ก.
- Segue๋ฅผ ์ด์ฉํ์ฌ ์คํ ๋ฆฌ๋ณด๋์์ ํ๊ตญ์ ์ถํ์์ ๋ณด์ฌ์ฃผ๋ TableView์ Cell์ ํด๋ฆญํ๋ฉด, ํด๋ฆญ๋ Cell์ ํด๋นํ๋ ์ถํ์์ ์์ธ ์ ๋ณด๋ฅผ ๋ณด์ฌ์ฃผ๋ View๋ก ํ๋ฉด์ ํ์ด ๋๊ฒ ๊ตฌํํ์์ต๋๋ค. `prepare()`๋ฉ์๋๋ฅผ ์ค๋ฒ๋ผ์ด๋ํ์ฌ ๋ฐ์ดํฐ๋ฅผ ์ ์กํ ๋, `sender`๋ก ์ ๋ฌ๋๋ ์์ธ ์ ๋ณด๋ฅผ ๋ํ๋ด๋ ๋ฐ์ดํฐ๊ฐ cell์๋ ์๊ธฐ ๋๋ฌธ์ ์์ธ ์ ๋ณด๋ฅผ ๋ณด์ฌ์ฃผ๋ View์ ์ฌ๋ฐ๋ฅธ ๋ฐ์ดํฐ๋ฅผ ์ ์กํ์ง ๋ชปํ๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์์ต๋๋ค.
- TableView Delegate์ ๋ฉ์๋์ธ `tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)`๋ฅผ ์ฌ์ฉํด ์์ธ ์ ๋ณด๋ฅผ ๋ณด๊ณ ์ถ์ Cell์ ์ ํํ๋ฉด ์ ํ๋ ์
์ row์ ํด๋นํ๋ Item์ `performSegue`๋ฉ์๋์ `sender`๋ก ์ ๋ฌํด ์ฃผ์ด์ ํด๋น ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์์ต๋๋ค.
```swift
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.performSegue(withIdentifier: "ShowItemDetail", sender: expositionItems[indexPath.row])
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let nextViewController: ExpositionItemDetailViewController = segue.destination as? ExpositionItemDetailViewController,
let item: ExpositionUniverselleItem = sender as? ExpositionUniverselleItem else {
return
}
nextViewController.item = item
}
```
#### ๋ฉ์ธํ์ด์ง ์ด๋๋ฒํผ
|Before|After|
|:---:|:---:|
|<img src="https://i.imgur.com/op4N0rw.gif" width="200" height="400"/>|<img src="https://i.imgur.com/wHQ3Eqn.gif" width="200" height="400"/>|
```swift
showKoreanItemListButton.titleLabel?.text = "ํ๊ตญ์ ์ถํ์ ๋ณด๋ฌ๊ฐ๊ธฐ"
```
- MainVC ๋ด๋ถ์์ ๋ค์ ํ๋ฉด์ผ๋ก ์ด๋ํ๊ธฐ ์ํด ํด๋น ์ฝ๋๋ฅผ ์ด์ฉํด ์ํ๋ text๋ฅผ ๊ตฌํ์ ํ์์ผ๋, ๋ฒํผ์ ํด๋ฆญํ๋ฉด ๋ฒํผ์ ํด๋ฆญํ ํ์ ํ๋ฉด ์ด๋ ํ ๋ค์ Main ํ๋ฉด์ผ๋ก ๋๋์์์ ๋ ์ง์ ํ text๊ฐ ์๋ ๋ฒํผ์ด ๊ฐ์ง๊ณ ์๋ ์๋์ text์ธ "Button" ์ด ๋ณด์ฌ์ง๋ ๋ฌธ์ ๊ฐ ์์์ต๋๋ค.
```swift
showKoreanItemListButton.setTitle("ํ๊ตญ์ ์ถํ์ ๋ณด๋ฌ๊ฐ๊ธฐ", for: .normal)
```
- Button์ State๊ฐ `.nomal`์ผ๋์ Title์ด "Button"์ด์ฌ์ ๋ฐ์ํ๋ ๊ฒ์ผ๋ก ํ์
ํ์ผ๋ฉฐ, Button์ `titleLabel`์ `text`๋ฅผ ์ง์ ๋ฐ๊พธ๋ ๋ฐฉ์์ด ์๋ `setTitle(_,for:)`๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ๋ฒํผ์ State์ ๋ฐ๋ฅธ Title์ ์ง์ ํด์ค์ ํด๊ฒฐํ์์ต๋๋ค.
#### Label ์ค์ ๊ณผ Dynamic Type
- MainView์ Label์ font, textAlignment, numberOfLines, lineBreakMode ๋ฑ์ Label์ ์ค์ ์ ํ ๋, ์ฝ๋๋ฅผ ์ค๋ณตํด์ ์์ฑํ๊ฒ ๋์์ต๋๋ค.
- ์ค๋ณต๋ ์ฝ๋๋ฅผ ์ค์ด๊ณ ์ Inheritance ๋ฐ Extention์ ํ์ฉํ์ฌ ์ค๋ณต๋ ์ฝ๋๋ฅผ ์ค์์ต๋๋ค.
#### Main VC์ Label์ ์๋ก๋ค๋ฅธ Font ์ ์ฉ
- `range`์ ๋ฒ์๋ฅผ ์ด๋ป๊ฒ ์ง์ ํด์ฃผ์ด์ผ ํ ์ง์ ๋ํ ๊ณ ๋ฏผ์ด ์์๊ณ , String Type์ ๋ฉ์๋์ธ `prefix`๋ฅผ ์ฌ์ฉํด์ ์ง์ ํด ์ค ์ ์์์ต๋๋ค.
- ๊ธฐ๋ณธ์ ์ธ Font๋ฅผ Dynamic Type์ผ๋ก ์ค์ ํ ํ, ์ํ๋ ๋ฒ์์ attributedText๋ฅผ ์ง์ ํด์คฌ์ต๋๋ค. ํ์ง๋ง attributedText๊ฐ ์ง์ ๋ ๋ฒ์ ์ด์ธ์ Text๋ Dynamic Type์ด ์๋ ์ฒ์ ์ค์ ๋ Font๋ก ๊ณ ์ ๋๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
- ์ ์ฒด ๋ฒ์์ attributedText๋ฅผ ์ง์ ํด ์ค ํ ์ํ๋ ๋ฒ์์ attributedText๋ฅผ ์ถ๊ฐ์ ์ผ๋ก ์ง์ ํด ์ค์ ์ด๋ฅผ ํด๊ฒฐํ์์ต๋๋ค.
#### Title Label ์ค๋ฐ๊ฟ
- Title Label์ ์ค๋ฐ๊ฟํ๊ธฐ ์ํด์ ์ ๊ท์ ์ฌ์ฉ์ ๊ณ ๋ฏผ ํ์์ง๋ง, ๋๋ฌด ๋ฌด๊ฑฐ์ด ๋ด์ฉ์ด๋ผ๊ณ ์๊ฐ๋์ด ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๊ณ ๋ฏผํ์ต๋๋ค.
- ๊ณ ๋ฏผ ๋์, Title Label์ text์์ ์ค๋ฐ๊ฟ ํ๊ณ ์ ํ๋ ๋ถ๋ถ์ธ '('์ index๋ฅผ ๊ตฌํ ํ, `inset(_, at:)`๋ฉ์๋๋ฅผ ์ด์ฉํด์ ์ํ๋ index ๋ถ๋ถ์ '\n'๋ฅผ insert ํ์ต๋๋ค.
#### ๊ฐ ํ๋ฉด์ ๊ณ ์ ๋ฐฉํฅ ์ง์
- AppDelegate์์ ํ๋ฉด ๋ฐฉํฅ ๊ณ ์ ํ๋ ๋ฐฉ๋ฒ๋ ์๋ ๊ฒ์ ์์์ง๋ง, ์์ง AppDelegate์ ๋ํ ๊ณต๋ถ๊ฐ ๋ถ์กฑํ๋ค๊ณ ์๊ฐํ์ต๋๋ค. ๊ทธ๋์ View Controller์ `supportedInterfaceOrientations` ํ๋กํผํฐ๋ฅผ ์ด์ฉํด ํ๋ฉด ๋ฐฉํฅ์ ๊ณ ์ ํ๋๋ก ๊ตฌํํ์์ต๋๋ค.
#### View๋ฅผ ๊ด๋ฆฌํ๋ ๊ฐ์ฒด ๊ตฌํ
- ๋ฆฌ๋ทฐ์ด์ ํ ์ํ ํ VC๋ View์ ๊ฐ๊น๊ณ ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๊ณ ๊ฐ๊ณตํ๋ ๋ฑ์ ๋ก์ง์ ๊ดํ ๋ด์ฉ์ ์ ํ์๊ฐ ์๋ค๋ ๊ฒฐ๋ก ์ ์ป์์ต๋๋ค.
- MainVC์์ ์ฒ๋ฆฌํ๋ ๋ก์ง์ ๊ด๋ฆฌํ๋ `MainViewManager`๊ฐ์ฒด๋ฅผ ๊ตฌํํ์ฌ ํด๋น ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
#### MainViewManager์ ๋ฐ์ดํฐ ์ฒ๋ฆฌ ๋ก์ง ๋ฐฉ๋ฒ
- `MainViewManager`๊ฐ์ฒด์ ์ ์ฅ๋๊ณ ๋ถ๋ฌ์ค๋ ๋ก์ง์ ๋ฉ์๋๋ฅผ ํตํด์ ๊ตฌํํ๋ ค๊ณ ํ์ต๋๋ค. ๋ฉ์๋๋ฅผ ํตํด ๊ตฌํํ๊ฒ ๋๋ฉด ๊ฐ์ฒด์ ๋ง์ ๋ฉ์๋๋ฅผ ๊ฐ์ง๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.
- ์ ์ฅ ํ๋กํผํฐ์ ์ฐ์ฐ ํ๋กํผํฐ๋ฅผ ๋ฐ๋ก ๊ตฌํํด ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ ๋ ์ฐ์ฐ ํ๋กํผํฐ์ `set`์ ์ด์ฉํ์ฌ ์ ์ฅ ํ๋กํผํฐ์ ์ํ๋ ๋ก์ง์ ๊ฒฐ๊ณผ๋ฅผ ์ ์ฅํ๋๋ก ๊ตฌํํ์๊ณ , ์ฐ์ฐ ํ๋กํผํฐ์ `get`์ ํตํด ์ ์ฅํ๋กํผํฐ์ ๋ฐ์ดํฐ๋ฅผ ์ํ๋ ํํ๋ก ๋ถ๋ฌ์ค๊ฒ ๊ตฌํํ์ต๋๋ค.
<br>
## 7. ํ๋ก์ ํธ ์ํ ์ค ํต์ฌ ๊ฒฝํ
- JSON ์ดํด์ ํ์ฉ
- ScrollVeiw์ ์ดํด์ ํ์ฉ
- tableView์ Cell์ ์ดํด์ ํ์ฉ
- ํ๋ฉด ๊ฐ ๋ฐ์ดํฐ ์ ๋ฌ
- lldb ํ์ฉ
- ๋ค์ํ ๊ธฐ๊ธฐ์ ๋์ํ ์ ์๋ ์คํ ๋ ์ด์์์ ์ ์ฉ
- Word Wrapping, Line Wrapping, Line Break ๋ฐฉ์์ ์ดํด ๋ฐ ํ์ฉ
- Dynamic Types์ ์ ์ฉํด ํ
์คํธ ์ ๊ทผ์ฑ ํฅ์
<br>
## 8. ์ฐธ๊ณ ๋งํฌ
- Apple Developer
- [UITableView](https://developer.apple.com/documentation/uikit/uitableview)
- [Table views](https://developer.apple.com/documentation/uikit/views_and_controls/table_views)
- [Filling a table with data](https://developer.apple.com/documentation/uikit/views_and_controls/table_views/filling_a_table_with_data)
- [UIControl.State](https://developer.apple.com/documentation/uikit/uicontrol/state)
- [Configuring the cells for your table](https://developer.apple.com/documentation/uikit/views_and_controls/table_views/configuring_the_cells_for_your_table)
- [JSONDecoder](https://developer.apple.com/documentation/foundation/jsondecoder)
- [Using JSON with Custom Types](https://developer.apple.com/documentation/foundation/archives_and_serialization/using_json_with_custom_types)
- [Encoding and Decoding Custom Types](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types)
- [HIG - Text views](https://developer.apple.com/design/human-interface-guidelines/components/content/text-views)
- [HIG - View](https://developer.apple.com/design/human-interface-guidelines/components/layout-and-organization/labels)
- [Displaying Text Content in iOS](https://developer.apple.com/library/archive/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/UsingTextClasses/UsingTextClasses.html)
- [NSAttributedString](https://developer.apple.com/documentation/foundation/nsattributedstring)
- [HIG - Typography](https://developer.apple.com/design/human-interface-guidelines/foundations/typography)
---
[๐ ๋งจ ์๋ก ์ด๋ํ๊ธฐ](#๋ง๊ตญ๋ฐ๋ํ)