Skip to content

Commit 365ba02

Browse files
committed
Create 250228 UICollectionViewDiffableDataSource,_animatingDifferences.md
1 parent 6e84bbc commit 365ba02

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# 250228 UICollectionViewDiffableDataSource, ์• ๋‹ˆ๋ฉ”์ด์…˜, ์„ฑ๋Šฅ
2+
3+
`UICollectionViewDiffableDataSource`์˜ `apply` ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ ํŒŒ๋ผ๋ฏธํ„ฐ `animatingDifferences`๋ฅผ `true`๋กœ ํ•˜๋Š”๊ฒƒ๊ณผ `false`๋กœ ํ•˜๋Š” ๊ฒƒ์ด ๋‚ด๋ถ€ ๋™์ž‘ ์ฐจ์ด
4+
5+
2์›” 28์ผ (๊ธˆ)
6+
7+
# ํ•™์Šต๋‚ด์šฉ
8+
9+
- `animatingDifferences: true`๋Š” ๋ฐ์ดํ„ฐ ๊ฐ„ ์ฐจ์ด๋ฅผ ๊ณ„์‚ฐํ•ด ์• ๋‹ˆ๋ฉ”์ด์…˜๊ณผ ํ•จ๊ป˜ ์—…๋ฐ์ดํŠธํ•˜๋ฉฐ, `false`๋Š” ์• ๋‹ˆ๋ฉ”์ด์…˜ ์—†์ด ๋ณ€๊ฒฝ์‚ฌํ•ญ๋งŒ ์ ์šฉํ•จ
10+
- iOS 13~14์—์„œ๋Š” false๊ฐ€ ๋‹จ์ˆœ reloadData์ฒ˜๋Ÿผ ๋™์ž‘ํ–ˆ์œผ๋‚˜, iOS 15๋ถ€ํ„ฐ๋Š” diff ๊ณ„์‚ฐ ํ›„ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์—ฌ๋ถ€๋งŒ ๊ฒฐ์ •๋œ๋‹ค๊ณ  ํ•œ๋‹ค.
11+
- true์ผ ๋•Œ ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ์…‹ ์—…๋ฐ์ดํŠธ ์‹œ, ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ ์šฉ์œผ๋กœ ์ธํ•ด ์ถ”๊ฐ€ ์…€ ์ƒ์„ฑ, UI ์—…๋ฐ์ดํŠธ ์ด๋ฒคํŠธ๊ฐ€ ๋งŽ์ด ๋ฐœ์ƒํ•˜์—ฌ CPU, GPU, ๋ฉ”๋ชจ๋ฆฌ ๋ถ€ํ•˜๊ฐ€ ์ฆ๊ฐ€ํ•˜๊ฒŒ ๋œ๋‹ค.
12+
13+
# ๊ณ ๋ฏผํ•œ ์  / ํ•ด๊ฒฐ๋ฐฉ๋ฒ•
14+
15+
### iOS ๋ฒ„์ „๋ณ„ ๋™์ž‘ ์ฐจ์ด ์ดํ•ด
16+
17+
iOS 13~14์—์„œ๋Š” `animatingDifferences: false`๊ฐ€ ์ „์ฒด reload์ฒ˜๋Ÿผ ๋™์ž‘ํ•ด ์„ฑ๋Šฅ ๋ถ€๋‹ด์ด ์ ์—ˆ์œผ๋‚˜, iOS 15 ์ด์ƒ์—์„œ๋Š” diff ์—ฐ์‚ฐ์ด ์ˆ˜ํ–‰๋˜๋ฏ€๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์—ฌ๋ถ€๋งŒ ๋‹ฌ๋ผ์ง„๋‹ค.
18+
19+
* [https://www.jessesquires.com/blog/2021/07/08/diffable-data-source-behavior-changes-and-reconfiguring-cells-in-ios-15/](https://www.jessesquires.com/blog/2021/07/08/diffable-data-source-behavior-changes-and-reconfiguring-cells-in-ios-15/)
20+
* [https://developer.apple.com/videos/play/wwdc2021/10252](https://developer.apple.com/videos/play/wwdc2021/10252)
21+
22+
### ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ ์—…๋ฐ์ดํŠธ ์ตœ์ ํ™”
23+
24+
๋Œ€๋Ÿ‰์˜ ์…€ ์—…๋ฐ์ดํŠธ ์‹œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ ์šฉ์œผ๋กœ ๋ถˆํ•„์š”ํ•œ ์…€ ์ƒ์„ฑ๊ณผ UI ์—…๋ฐ์ดํŠธ๊ฐ€ ๋ฐœ์ƒํ•ด ์„ฑ๋Šฅ ์ €ํ•˜๋ฅผ ์œ ๋ฐœํ•œ๋‹ค. ์ด์— ๋”ฐ๋ผ ์ƒํ™ฉ์— ๋งž๊ฒŒ animatingDifferences๋ฅผ `false`๋กœ ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜, iOS 15 ์ด์ƒ์˜ `applySnapshotUsingReloadData`๋ฅผ ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๊ณ ๋ คํ•˜๋ฉด ๋˜๊ฒ ๋‹ค.
25+
26+
- [https://developer.apple.com/forums/thread/706349#:~:text=Generally%20speaking%2C%20when%20you%20are,animation%20for%20the%20inserted%20cells](https://developer.apple.com/forums/thread/706349#:~:text=Generally%20speaking%2C%20when%20you%20are,animation%20for%20the%20inserted%20cells)
27+
- [https://stackoverflow.com/questions/73242482/uicollectionview-snapshot-takes-too-long-to-re-apply#:~:text=Using%20,rows%20by%20making%20this%20change](https://stackoverflow.com/questions/73242482/uicollectionview-snapshot-takes-too-long-to-re-apply#:~:text=Using%20,rows%20by%20making%20this%20change)
28+
29+
### Diff ์—ฐ์‚ฐ ๋น„์šฉ๊ณผ UI ์—…๋ฐ์ดํŠธ ๋ถ€๋‹ด
30+
31+
diff ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ `O(n)` ์„ ํ˜• ๋ณต์žก๋„๋ฅผ ๊ฐ€์ง€์ง€๋งŒ, ๋ณ€๊ฒฝ ํ•ญ๋ชฉ ์ˆ˜๊ฐ€ ๋งŽ์•„์งˆ์ˆ˜๋ก UI ์—…๋ฐ์ดํŠธ ๋ฐ ์…€ ์žฌ์ƒ์„ฑ ๋น„์šฉ์ด ๋ˆ„์ ๋œ๋‹ค. ๋”ฐ๋ผ์„œ, ํ•„์š”ํ•œ ๊ฒฝ์šฐ ๋ฐ์ดํ„ฐ ํŽ˜์ด์ง•์ด๋‚˜ ๋ฐฐ์น˜ ์ฒ˜๋ฆฌ๋ฅผ ํ†ตํ•ด ํ•œ ๋ฒˆ์— ์ฒ˜๋ฆฌํ•˜๋Š” ์•„์ดํ…œ ์ˆ˜๋ฅผ ์ œํ•œํ•˜๋Š” ์ „๋žต์ด ์ข‹๊ฒ ๋‹ค.
32+
33+
### ์‹ค์ œ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์—์„œ์˜ ์„ฑ๋Šฅ ๋ถ„์„ ์ค‘์š”์„ฑ
34+
35+
Instruments ๋ฐ ๊ฐœ๋ฐœ์ž ์ปค๋ฎค๋‹ˆํ‹ฐ์˜ ์‚ฌ๋ก€๋ฅผ ํ†ตํ•ด ์„ฑ๋Šฅ ํ…Œ์ŠคํŠธ์˜ ์ค‘์š”์„ฑ์„ ์žฌํ™•์ธํ•˜์˜€์œผ๋ฉฐ, ์• ๋‹ˆ๋ฉ”์ด์…˜ ์˜ต์…˜ ์„ ํƒ์ด UX์™€ ์„ฑ๋Šฅ ์‚ฌ์ด์˜ ํŠธ๋ ˆ์ด๋“œ์˜คํ”„์ž„์„ ๋ช…ํ™•ํžˆ ์ธ์ง€ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.
36+
37+
# ๋А๋‚€์ 
38+
39+
- diffable data source์˜ ๋‚ด๋ถ€ ๋™์ž‘๊ณผ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์˜ต์…˜์— ๋”ฐ๋ฅธ ์„ฑ๋Šฅ ์ฐจ์ด๋ฅผ ๋ช…ํ™•ํ•˜๊ฒŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ์—ˆ์Œ.
40+
- ์ƒํ™ฉ์— ๋งž๋Š” ์ตœ์ ์˜ ์—…๋ฐ์ดํŠธ ์ „๋žต ์ˆ˜๋ฆฝ์˜ ์ค‘์š”์„ฑ์„ ์žฌํ™•์ธํ•˜๋ฉฐ, ์‹ค์ œ ํ…Œ์ŠคํŠธ ๋ฐ ํฌ๋Ÿผ ์‚ฌ๋ก€๊ฐ€ ํฐ ๋„์›€์ด ๋จ.
41+
- ๋ฐ์ดํ„ฐ ์–‘๊ณผ ์—…๋ฐ์ดํŠธ ๋ฐฉ์‹์— ๋”ฐ๋ผ ์„ฑ๋Šฅ ์ตœ์ ํ™”๋ฅผ ์œ„ํ•ด ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‚ฌ์šฉ ์—ฌ๋ถ€๋ฅผ ์‹ ์ค‘ํ•˜๊ฒŒ ์„ ํƒํ•ด์•ผ ํ•œ๋‹ค๋Š” ์ ์„ ๊นจ๋‹ฌ์Œ
42+
43+
---
44+
45+
# ์ฐธ๊ณ  ๋งํฌ
46+
47+
- [ChatGPT - apply animatingDifferences ์„ฑ๋Šฅ ์ฐจ์ด ๋ถ„์„](https://hackmd.io/@OsPD18twQM2Jv-q7O5bkWQ/rkBYnu0qyx)
48+
- [Apple ๊ฐœ๋ฐœ์ž ๋ฌธ์„œ ๋ฐ WWDC ์˜์ƒ](https://developer.apple.com/videos/play/wwdc2021/10252/#:~:text=changes%2C%20its%20representation%20in%20diffable,First%2C%20let%27s)
49+
- [StackOverflow: diffable data source diff ๊ณ„์‚ฐ ๊ด€๋ จ](https://stackoverflow.com/questions/67996442/why-dispatchqueue-main-async-is-required-when-using-coredata-nsfetchedresultsco#:~:text=,method%20exclusively%20from%20the%20main)
50+
- [StackOverflow: UICollectionView ์Šค๋ƒ…์ƒท ์„ฑ๋Šฅ ์ด์Šˆ](https://stackoverflow.com/questions/73242482/uicollectionview-snapshot-takes-too-long-to-re-apply#:~:text=Using%20,rows%20by%20making%20this%20change)
51+
- [Jesse Squires ๋ธ”๋กœ๊ทธ: diffable data source ์ตœ์ ํ™”](https://www.jessesquires.com/blog/2024/12/19/diffable-data-source-main-actor-inconsistency/#:~:text=involved%20in%20creating%20cells%2C%20measuring,number%20of%20items%20populated%20in)
52+
- [Apple Developer Forums](https://forums.developer.apple.com/forums/thread/706349#:~:text=Generally%20speaking%2C%20when%20you%20are,animation%20for%20the%20inserted%20cells)

0 commit comments

Comments
ย (0)