Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Responder Chainを使って コードをスッキリさせたい - 第1回 HAKATA.s...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ukitaka
April 16, 2018
Programming
1.5k
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Responder Chainを使って コードをスッキリさせたい - 第1回 HAKATA.swift
https://hakata-swift.connpass.com/event/81656/
での発表です。
ukitaka
April 16, 2018
Transcript
58 slides
Responder ChainΛͬͯ ίʔυΛεοΩϦ͍ͤͨ͞ HAKATA.swift @ukitaka
twitter: @ukitaka_ github: @ukitaka Yuki Takahashi
ࣗݾհ ❤ ؔܕϓϩάϥϛϯάɺDDD ✏ ܕγεςϜɺίϯύΠϥ ϨΠϠʔ
ࠓͷ
͍͖ͳΓͰ͕͢ɺ ͜ΜͳέʔεΛߟ͑ͯΈΔ
Cellͷதͷ ϘλϯΛλοϓͨ͠Β Alert / ActionSheetग़͍ͨ͠
None
͋Γ͕ͪ
ຯʹΊΜͲ͍͘͞ • UIAlertControllerΛग़͢ʹViewControllerͰ ॲཧΛ͢Δඞཁ͕͋Δ • CellViewControllerͳΜͯΒͳ͍ • ViewControllerCellͷϘλϯΛ(ී௨)ࢀ র͍ͯ͠ͳ͍
Α͋͘Δରॲ๏ • DelegateΛҾճ͢ • ֊͕ਂ͘ͳΕͳΔ΄Ͳਏ͍ • ViewߏͷมԽʹऑ͍
ͳΜͱ͔͍ͨ͠
ݪʹཱͪฦͬͯMVC
MVCͰͲ͏͋Δ͖ʁ
None
None
ϢʔβΞΫγϣϯͷॲཧ • MVCʹ͓͚ΔControllerͷΑ͏ͳΦϒδΣΫ τʹ௨Λͯ͠ϢʔβΞΫγϣϯड͚ͱΔͷ ͕ී௨ • MVCʹݶΒͣɺͲͷΞʔΩςΫνϟͰ͋ͬͯ ಉ͡
௨Λ͠Α͏
ཧ
௨͢ΔଆΠϝʔδ .notifyΛݺͿ͚ͩ
௨Λड͚औΔଆΠϝʔδ ͍͍ײ͡ʹDelegateͰड͚औΕΔ
DelegateΛҾճ͢ඞཁ͕ͳ͍ DelegateύλʔϯͷΑ͏ͳ Πϝʔδ
ͦ͜Ͱ Responder Chain
= UIResponderͷ࿈ͳΓ
None
UIResponder • UIReponder = ϢʔβͷೖྗΛर͑Δͭ • ͋ΔsubviewͰΠϕϯτΛर͏ͱॲཧͰ͖Δͱ ͜Ζ·Ͱ࣍ʑʹॲཧΛճ͍ͯ͘͠ • self.next
Ͱ࣍ͷResponder͕औΕΔ = Responder Chain
None
UIResponder • ResponderChain্ʹવViewController ͍Δʂ • DelegateΛҾ͖ճ͢·Ͱͳ͘ɺ͢Ͱʹͭͳ ͕͍ͬͯΔ • ͜Εʹ͔ͬΕ͍͍ײ͡ʹViewControllerʹ ʮ௨ʯͰ͖ͦ͏ʂ
ͳΜ͔͑ͦ͏
Ͳ͏Δ͔ʁ
ActionΛఆٛ͢Δ
DelegateΛఆٛ͢Δ
ViewEventΛఆٛ͢Δ ୭͕ϋϯυϧ͢Δ͔ͱɺ Ͳ͏σΟεύον͢Δ͔ΛܾΊΔɻ
ViewEventΛఆٛ͢Δ
UIResponderΛ֦ு͢Δ Responder ChainΛḷͬͯɺ ΠϕϯτΛϋϯυϧͰ͖ΔͭΛݟ͚ͭΔ
ʂ
௨͢ΔଆΠϝʔδ .notifyΛݺͿ͚ͩ
௨Λड͚औΔଆΠϝʔδ ͍͍ײ͡ʹDelegateͰड͚औΕΔ
ཧͷੈք͕࣮ݱͨ͠
ྑ͍ • DelegateΛViewͷਂ͍֊·ͰҾճ͢ඞཁ͕ ͳ͘ͳͬͨ • Viewͷ֊͕มԽͨ͠ͱͯ͠ɺίʔυͷม ߋ͕ෆཁɻViewͷมߋʹڧ͍ɻ
มΘΒͳ͍ • ͋ΔΠϕϯτΛड͚औΔͨΊͷprotocol࣮ ͠ΕΛίϯύΠϧ࣌ʹݕग़Ͱ͖ͳ͍ • ͜ΕDelegateઃఆ͠ΕͰಉ͡ • ࣮ࡍʹಈ͔͢ or ςετͰΧόʔ
RxCocoaͷԠ༻
RxCocoa + Responder Chain • RxΛ͍ͬͯͯಉ͕͡ى͜Δ • RxDataSourcesΛ͍ͬͯͯɺCellͷதͷΠ ϕϯτर͑ͳ͍ •
Responder Chainʹྲྀͯ͠͠·͓͏
ukitaka/RxResponderChain
͍ํ
ࡶʹResponder Chainʹྲྀ͢ Ϙλϯ͕λοϓ͞ΕͨΒ
ࡶʹResponder Chainʹྲྀ͢ దͳܕʹมͯ͠
ࡶʹResponder Chainʹྲྀ͢ Responder Chainʹྲྀ͢
ࡶʹVCͰड͚औΔ ViewControllerͰ ܕΛࢦఆͯ͠ड͚औΔ
গ͚࣮ͩ͠ΛΈΔ
࣮ͷཪଆ ࠇຐज़ʹΑ֤ͬͯUIResponderΦϒδΣΫτʹ PublishSubjectΛ࣋ͨͤΔ
࣮ͷཪଆ self.rx.responderChain Λੜ͢
࣮ͷཪଆ ͜ͷΦϒδΣΫτObserverType
࣮ͷཪଆ ʹEvent͕ྲྀΕ͖ͯͨΒ ResponderChainΛḷͬͯ
࣮ͷཪଆ ͖ͬ͞ੜͨ͠PublishSubjectʹ ΠϕϯτΛྲྀ͢
࣮ͷཪଆ ड͚औΔͱ͖ܕͰfilter
·ͱΊ
ResponderChain • View → ViewControllerResponder Chainܨ ͕͍ͬͯΔ • ௨ʹ͑Δ /
ָʹॻ͚Δ / มߋʹڧ͍
͓ΘΓ
More Decks by ukitaka
See All by ukitaka
あなたの知らない「動画広告」の世界 - iOSDC Japan 2025
ukitaka
0
1.9k
CSの生産性改善を支える分析環境 Mercari CS/CRE Tech Talk #1
ukitaka
1
3.2k
switchのexhaustiveness/redundancy チェック 理論と実装 わいわいswiftc #8 @ukitaka
ukitaka
0
280
SwiftのDemanglerを書く @ わいわいswiftc番外編
ukitaka
0
510
Swiftの型システムに入門する - iOSDC Japan 2018
ukitaka
10
7.5k
理論から入門するswift/lib/Sema - わいわいswiftc #1
ukitaka
5
1.9k
Realmの処理を再利用可能かつ合成可能にする
ukitaka
0
1k
マルチスレッドRxSwift @ 社内RxSwift勉強会
ukitaka
5
1.3k
今日こそ理解するHot / Cold @社内RxSwift勉強会
ukitaka
14
3k
Other Decks in Programming
See All in Programming
将来の標準フォーマッター?ktfmtを深堀る
t45k
0
220
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
270
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
190
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
190
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
950
疎結合とは何か?ソフトウェア設計における結合バランスについて考える #phpcon_niigata
kajitack
2
380
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
250
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
2.5k
Ruby から Emacs を操作したい
phigasui
0
360
祈るテストから、探索するテストへ 〜Lincheckではじめる並行処理テスト〜
yyh_gl
0
350
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
320
Featured
See All Featured
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
70
69k
The Cost Of JavaScript in 2023
addyosmani
56
10k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
670
Product Roadmaps are Hard
iamctodd
55
13k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
360
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
550