Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
tableViewとcoolectionviewのパフォーマンスチューニング
Search
kichikuchi
February 02, 2017
Technology
1
560
tableViewとcoolectionviewのパフォーマンスチューニング
kichikuchi
February 02, 2017
Tweet
Share
More Decks by kichikuchi
See All by kichikuchi
swiftにおける遅延評価
kichikuchi
0
2.8k
AB Tests in Mobile App
kichikuchi
1
1.9k
GameplayKit, GKRandomSource, GKRandomDistribution
kichikuchi
1
270
Other Decks in Technology
See All in Technology
#TRG24 / David Cuartielles / Post Open Source
tarugoconf
0
580
デジタルアイデンティティ人材育成推進ワーキンググループ 翻訳サブワーキンググループ 活動報告 / 20250114-OIDF-J-EduWG-TranslationSWG
oidfj
0
520
AWS re:Invent 2024 re:Cap Taipei (for Developer): New Launches that facilitate Developer Workflow and Continuous Innovation
dwchiang
0
160
Oracle Base Database Service:サービス概要のご紹介
oracle4engineer
PRO
1
16k
re:Invent 2024のふりかえり
beli68
0
110
AWSの生成AIサービス Amazon Bedrock入門!(2025年1月版)
minorun365
PRO
7
470
コロプラのオンボーディングを採用から語りたい
colopl
5
970
信頼されるためにやったこと、 やらなかったこと。/What we did to be trusted, What we did not do.
bitkey
PRO
0
2.2k
[IBM TechXchange Dojo]Watson Discoveryとwatsonx.aiでRAGを実現!座学①
siyuanzh09
0
110
EMConf JP の楽しみ方 / How to enjoy EMConf JP
pauli
2
150
30分でわかる「リスクから学ぶKubernetesコンテナセキュリティ」/30min-k8s-container-sec
mochizuki875
3
440
三菱電機で社内コミュニティを立ち上げた話
kurebayashi
1
350
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
What's in a price? How to price your products and services
michaelherold
244
12k
Producing Creativity
orderedlist
PRO
343
39k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
The Cost Of JavaScript in 2023
addyosmani
46
7.2k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
The Invisible Side of Design
smashingmag
299
50k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
210
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.5k
Transcript
NJOOFͰ࣮ફͨ͜͠ͱ ٠ل(.01&1"#0JOD ϖύϘςοΫΧϯϑΝϨϯε 5BCMF7JFX $PMMFDUJPO7JFXͷ ύϑΥʔϚϯενϡʔχϯά
JPTΤϯδχΞ ٠ل NJOOFࣄۀ෦ϓϩμΫτνʔϜ
·ͣͪ͜ΒΛ͝ཡԼ͍͞
ϗʔϜ 5BCMF7JFX $PMMFDUJPO7JFX $PMMFDUJPO7JFX
χϡʔε 5BCMF7JFX
͓ؾʹೖΓ $PMMFDUJPO7JFX
ݕࡧ݁Ռ $PMMFDUJPO7JFX
NJOOF΄΅શͯͷը໘Ͱ 5BCMF7JFX·ͨ$PMMFDUJPO7JFX Λར༻͍ͯ͠·͢
ύϑΥʔϚϯεվળʹ ͜ΕΒͷνϡʔχϯά͕ ॏཁ
ࠓ͢͜ͱ NJOOFͰߦͬͨνϡʔχϯάํ๏Λ ࣮ྫΛڍ͛ͯհ͠·͢ ͳΊΒ͔λΠϜϥΠϯ ΧελϜΧϝϥϩʔϧ
ͳΊΒ͔λΠϜϥΠϯ
ͳΊΒ͔λΠϜϥΠϯͱ ࢭ·Βͣʹͣͬͱ ԼεΫϩʔϧͰ͖Δ
ͪͳΈʹͳΊΒ͔Ҏલɻɻɻ ϑολʔ͕දࣔ͞ΕΔ "1*ୟ͘ Ϧιʔεऔಘͨ͠Β UBCMF7JFXΛߋ৽ ࡞ݟΔຖʹ ͕ͪ࣌ؒൃੜ͍ͯͨ͠
࣮ॳظʹͬͨ͜ͱ ϑολʔ͕දࣔ͞ΕΔલʹ"1*ୟ͘ ˣ ࣍ϖʔδͷϦιʔεΛऔಘͨ͠Β UBCMF7JFXSFMPBE%BUB
SFMPBE%BUB ͢Δͱ ը໘͕Ұॠݻ·Δ
ॲཧ͕ॏ͍Օॴͷಛఆɾվળ FOE3FGSFTIJOH IFJHIU'PS3PX"U 5BCMF7JFX TJ[F'PS*UFN"U $PMMFDUJPO7JFX
FOE3FGSFTIJOH CFGPSF apiClient.download { result in switch result { case
.success: self.refreshControl.endRefreshing() self.tableView.reloadData() case .failure(_): break } } "1*Λୟ͍ͨޙৗʹFOE3FGSFTIJOH ͍ͯͨ͠
FOE3FGSFTIJOH BGUFS apiClient.download { result in switch result { case
.success: if refreshControl.isRefreshing { refreshControl.endRefreshing() } self.tableView.reloadData() case .failure(_): break } } JT3FGSFTIJOHΛར༻ͯ͠ ඞཁͳ͚࣌ͩFOE3FGSFTIJOH ͢Δ
ߴ͞ܭࢉॲཧCFGPSF func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{ let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")! return cell.frame.size.height } IFJHIU'PS3PX"UͰ DFMMΛΠϯελϯεԽ͍ͯͨ͠
ߴ͞ܭࢉॲཧBGUFS lazy var cellHeight: CGFloat = { let cell =
self.tableView.dequeueReusableCell(withIdentifier: "Cell")! return cell.frame.size.height }() func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return cellHeight } MB[ZWBSͰDFMM)FJHIUΛఆٛ͠ DFMMͷΠϯελϯεԽΛҰ͚ͩʹͨ͠
λΠϜϥΠϯ͕ͳΊΒ͔ʹ
ΧελϜΧϝϥϩʔϧ
ΧελϜΧϝϥϩʔϧͱ Ҏલࣸਅͷબ࣌ʹ σϑΥϧτͷΧϝϥϩʔϧ Λ༻͍ͯͨ͠ͷͰ ࡞Ո͞Μ࡞ը૾Λ ొ͢Δ࣌ʹ Կ։͔ͳ͍ͱ ͍͚ͳ͔ͬͨɻɻɻ ෳͷը૾Λ ҰʹબͰ͖Δ
Χϝϥϩʔϧ
ෳબ࣌ͷৄࡉ༷ DFMMΛλοϓͨ͠Β બͨ͠ॱ൪௨Γʹ ࣈΛߋ৽͍ͨ͠
ෳબ࣌ͷৄࡉ༷ DFMMΛλοϓͨ͠Β બͨ͠ॱ൪௨Γʹ ࣈΛߋ৽͍ͨ͠ ͻͱͭΊ
ෳબ࣌ͷৄࡉ༷ DFMMΛλοϓͨ͠Β બͨ͠ॱ൪௨Γʹ ࣈΛߋ৽͍ͨ͠ ;ͨͭΊ
ෳબ࣌ͷৄࡉ༷ DFMMΛλοϓͨ͠Β બͨ͠ॱ൪௨Γʹ ࣈΛߋ৽͍ͨ͠ ΈͬͭΊ
ෳબ࣌ͷৄࡉ༷ DFMMΛλοϓͨ͠Β બͨ͠ॱ൪௨Γʹ ࣈΛߋ৽͍ͨ͠ ΑͬͭΊ
ෳબ࣌ͷৄࡉ༷ DFMMΛλοϓͨ͠Β બͨ͠ॱ൪௨Γʹ ࣈΛߋ৽͍ͨ͠ ͬͺ͜Ε ΊΔʂ
ෳબ࣌ͷৄࡉ༷ DFMMΛλοϓͨ͠Β બͨ͠ॱ൪௨Γʹ ࣈΛߋ৽͍ͨ͠ ͍ͭ͜Β ߋ৽͢Δඞཁ͕͋Δʂ
࣮ॳظʹͬͨ͜ͱ ηϧશ෦ߋ৽͍ͨ͠ ˣ ૉʹUBCMF7JFXSFMPBE%BUB
ϚγϯεϖοΫ ࣗͷJ1IPOFTͰͳ͘ಈ͍ͯͨ ˣ σϓϩΠήʔτʹ͋͛ͯΈΜͳʹ৮ͬͯΒ͏ ˣ J1IPOFTϢʔβ͞Μ͔ΒηϧΛλοϓ͢Δຖ ʹը໘͕ݻ·Δͱͷใࠂ͕ɻɻɻ
ߋ৽ॲཧΛܰ͘͢Δඞཁ͕ʂʂ
ߋ৽ͷܰྔԽ WJTJCMF$FMMT XJMM%JTQMBZDFMM
WJTJCMF$FMMTͰݟ͑ͯΔ͚ͩߋ৽ collectionView.visibleCells.forEach { cell in if let indexPath = collectionView.indexPath(for:
cell) { cell.update(with: products[indexPath.row]) } } DFMMͷߋ৽͚ͩͰ͖ΔͷͰ SFMPBE%BUB ͱൺΔͱѹతʹܰྔʂʂ
͕ͨͩ͠ɻɻɻ ΪϦΪϦը໘֎ͷ બதͷηϧ͕͋Δ ͱߋ৽Ͱ͖ͳ͍ දࣔൣғ
XJMM%JTQMBZDFMM func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath:
IndexPath) { cell.update(with: products[indexPath.row]) } DFMM͕දࣔ͞ΕΔલʹߋ৽͢Δ͜ͱͰ ߋ৽࿙ΕΛͳ͘͢ʂ
J1IPOFTͰΩϏΩϏಈ͘
ͪͳΈʹ ࠓճWJTJCMF$FMMT XJMM%JTQMBZΛ͍·͕ͨ͠
ଞʹ৭ʑ͋Δ UBCMF7JFX tableView.reloadData() tableView.reloadRows(at: [IndexPath], with: UITableViewRowAnimation) tableView.reloadSections(sections: IndexSet, with:
UITableViewRowAnimation) DPMMFDUJPO7JFX collectionView.reloadData() collectionView.reloadItems(at: [IndexPath]) collectionView.reloadSections(sections: IndexSet)
ΉΈʹSFMPBE%BUB ͤͣ ߋ৽ྖҬʹԠͯ͡ϝιουΛ ͍͚Δʂ
·ͱΊ w ೋͭͷ࣮ྫΛڍ͛ͯνϡʔχϯάํ๏Λհͨ͠ w 6*ʹؔ͢Δॲཧඞཁͳ࣌ʹ͚ͩ͢Δ w FOE3FGSFTIJOH JT3FGSFTIJOHͷ͚࣌ͩݺͿ w ߴ͞ܭࢉॲཧ
IFJHIU'PS3PX"U TJ[F'PS*UFN"U ܰྔ ʹ͢Δ w ΉΈʹSFMPBE%BUB ͠ͳ͍ w WJTJCMF$FMMT SFMPBE3PXT SFMPBE4FDUJPOTͳͲͰࡁΉ ͳΒͦͪΒͰࡁ·͢