๐คฉ ์๋
ํ์ธ์ @junbangg
woong, jeremy ์
๋๋ค.
์กฐ๊ธ ๋ฆ์๊ฐ์ด์์ง๋ง step3๊น์ง ๊ผญ ์๋ฃํด๋ณด๊ฒ ์ต๋๋ค!
Step2 ์๋ฃํ์ฌ PR๋๋ฆฝ๋๋ค.
## ๐ค๊ณ ๋ฏผํ ๋ถ๋ถ
๐ tableViewDatasoruce -> DiffableDataSource๋ก ๋ณ๊ฒฝ
## ๐ญ ๊ถ๊ธํ ๋ถ๋ถ
### ๐ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์ง์
ํ๋ ๊ฒ์ ๊ฐ์งํ๋ ๋ฐฉ๋ฒ
1. ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ๊ฐ๋ ์๋ฆผ์ ์ฐพ์๋ณด๋ ์ค ๋๊ฐ์ง ๋ฐฉ๋ฒ์ ์ฐพ์์ต๋๋ค.
2. Notification์ ํ์ฉํ์ฌ ์ฑ์ด ๋ฐฑ๊ทธ๋ผ์ด๋ ํน์ ๋นํ์ฑํ ์ํ๊ฐ ๋์์ ๋ ํธ์ถํ๋ notification์
๋๋ค. ์๋์ ๊ฐ์ต๋๋ค.
**UIScene์ ํ์ฉ**
```swift
NotificationCenter.default.addObserver(self,
selector: #selector(sceneWillDeactivate),
name: UIScene.willDeactivateNotification,
object: nil)
```
**UIApplication์ ํ์ฉ**
```swift
NotificationCenter.default.addObserver(self,
selector: #selector(applicationWillInActive(_ :)),
name: UIApplication.willResignActiveNotification,
object: nil)
```
3. ๋ Notification์ด ํธ์ถ๋๋ ์กฐ๊ฑด์ ์๊ฒ ์ผ๋, ๋๊ฐ์ ์ฐจ์ด๊ฐ ์ดํด๊ฐ ๊ฐ์ง ์์ต๋๋ค.
4. stackOverFlow ํน์ ํ ๋ธ๋ก๊ทธ๋ฅผ ์ฐธ์กฐํ์ ๋, "์ฑํ๊ฒ์ด 13์ด์์ด๋ฉด UIScene๋ฅผ ์ฌ์ฉํ๋ฉฐ, 12์ดํ๋ผ๋ฉด UIApplication์ ์ฌ์ฉํ๋ผ." ๋ผ๋ ๋ง์ด ์์์ง๋ง ๋ ๋ค ์๋ํ๋๋ฐ ์ ๊ทธ๋ ๊ฒ ํด์ผํ์ง? ๋ผ๋ ์๊ฐ์ด ๋ค์์ต๋๋ค.
https://stackoverflow.com/questions/34744783/detect-ios-app-entering-background
5. ์ง๋ฌธ์์ฝ : ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์ง์
ํ๋ ๊ฒ์ ๊ฐ์งํ ๋, iOS13์ด์์ด๋ฉด UIScene.willResignActiveNotification์ผ๋ก ์ฒ๋ฆฌํด์ผํ๋ ์ด์ ๊ฐ ๋ฌด์์ธ๊ฐ์?
### ๐ snapShot์ ์ reload ํด์ค์ผํ๋๊ฐ?
```swift
private func configureSnapshot() {
var snapShot = NSDiffableDataSourceSnapshot<Section, DiaryData>()
snapShot.appendSections([.main])
snapShot.appendItems(diaryData)
snapShot.reloadSections([.main]) // ์น์
์ ๋ฆฌ๋ก๋ํ๋ ๋ฉ์๋
dataSource?.apply(snapShot)
}
```
1. ๋ค์ด์ด๋ฆฌ๋ฅผ ์์ฑํ๊ณ , DiaryViewController๋ก ๋ค์ ๋์์์ ๋, ํ
์ด๋ธ๋ทฐ๊ฐ ์
๋ฐ์ดํธ๋ฅผ ๋ฐ์ํ์ง ์๋ ๋ฌธ์ ๊ฐ ์์์ต๋๋ค.
2. ํ์ง๋ง, ์ ์ฝ๋์ ๋์ผํ๊ฒ `์น์
์ ๋ฆฌ๋ก๋ํ๋ ๋ฉ์๋`๋ฅผ ์ถ๊ฐ์ ์ผ๋ก ๊ตฌํํด์ฃผ๋ ์ ์์ ์ผ๋ก ์๋ํ์์ต๋๋ค.
3. ๊ทผ๋ฐ ๋ฆฌ๋ก๋๋ฅผ ํด์ค์ผํ๋ ์ด์ ๊ฐ ์์ํฉ๋๋ค.
4. ์ค๋
์ท์ ์ ์๋ `ํน์ ์์ ์์์ ๋ทฐ์ ์๋ ๋ฐ์ดํฐ์ ์ํ๋ฅผ ๋ณด์ฌ์ค๋ค.` ์ฆ, `diaryData`๊ฐ ๋ฐ๋์ด์ง ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ง๊ณ ์๋ ์์ ์์ ์ค๋
์ท์ ๋ค์ ๋ง๋ค์๊ธฐ์ ์
๋ฐ์ดํธ๋ ๋ฐ์ดํฐ๊ฐ UI์ ๋ด๊ฒจ์์ด์ผ ํ๋ ๊ฒ์ด ์๋๊ฐ? ๋ผ๊ณ ์๊ฐํ์ต๋๋ค.
5. ์ ๊ตณ์ด ๋ฆฌ๋ก๋๋ฅผ ํด์ค์ผ๋ง UI์์ ์
๋ฐ์ดํธ๊ฐ ๋๋๊ฑด์ง ์ด์ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค..
- dataSource์ snapShot์ ๋ค์ด๊ฐ์๋ hash id์ applyํด์ฃผ๋ ค๋ snapShot ์์ดํ
๋ค์ id๊ฐ ๊ฐ์์ ๋ณํ๋ฅผ ์ธ์งํ์ง ๋ชปํ ์ ์๋ค๊ณ ํด์ DiaryData์ uuid๋ฅผ ์๋ก updateํด์ฃผ๋ ๋ฐฉ์๋ ์๋๋ฅผ ํด๋ดค์ง๋ง ๋ฌธ์ ํด๊ฒฐ์๋ ์คํจํ์์ต๋๋ค. ๊ณต์๋ฌธ์์ ์ฌ๋ฌ ํฌ๋ผ๋ค์์๋ ์ด ๋ฌธ์ ๋ฅผ ์ธ๊ธํ๋๋ฐ ๋๋์ฒด ๋ฌด์์ด ๋ฌธ์ ์ผ๊น์...
### ๐ ๊ฐ์ฒด์งํฅ ์ํ ์ฒด์กฐ ์์น. ํ ์ค์ ์ ํ๋.
- ํ ์ค์ ์ ์ ํ๋๋ง ์จ์ผํ๋ค๋ ์์น์ด ์์ต๋๋ค. ์๋์ ๊ฐ์ ์ํฉ์์ laedingAnchor๋ฅผ ์ค์ ํด์ค๋ค๊ณ ํ์ ๋ ์ด ์์3๊ฐ๊ฐ ์ถ๊ฐ์ ์ผ๋ก ์์ฑ๋์ด์ผํ๋๋ฐ ๊ผญ ์ ํ๋๋ง ์ฌ์ฉํด์ผํ๋๊ฑด๊ฐ์..?
