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
Introducing the iOS Responder Chain
Search
lachlanroche
October 06, 2015
Programming
0
150
Introducing the iOS Responder Chain
Presented at Brisbane Cocoaheads, October 2015
lachlanroche
October 06, 2015
Tweet
Share
More Decks by lachlanroche
See All by lachlanroche
iPad Multitasking in iOS9
lachlanroche
0
160
Xcode keyboard tips
lachlanroche
1
44
Xcode build script tips
lachlanroche
0
64
Introducing Datomic
lachlanroche
0
51
Introducing Xamarin
lachlanroche
0
56
Other Decks in Programming
See All in Programming
プログラミング言語学習のススメ / why-do-i-learn-programming-language
yashi8484
0
130
ファインディの テックブログ爆誕までの軌跡
starfish719
2
1.1k
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
Conform を推す - Advocating for Conform
mizoguchicoji
3
690
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
富山発の個人開発サービスで日本中の学校の業務を改善した話
krpk1900
4
380
Writing documentation can be fun with plugin system
okuramasafumi
0
120
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
1
670
AWSマネコンに複数のアカウントで入れるようになりました
yuhta28
2
160
2,500万ユーザーを支えるSREチームの6年間のスクラムのカイゼン
honmarkhunt
6
5.2k
Compose でデザインと実装の差異を減らすための取り組み
oidy
1
300
CI改善もDatadogとともに
taumu
0
110
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Designing for Performance
lara
604
68k
For a Future-Friendly Web
brad_frost
176
9.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
RailsConf 2023
tenderlove
29
1k
Designing Experiences People Love
moore
139
23k
The Cost Of JavaScript in 2023
addyosmani
47
7.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Building Your Own Lightsaber
phodgson
104
6.2k
Raft: Consensus for Rubyists
vanstee
137
6.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Transcript
Introducing the Responder Chain Brisbane Cocoaheads Oct 2015 @lachlanroche
None
UIResponder • UIApplication • UIView (UIWindow) • UIViewController • SKNode
• AppDelegate in a new project
UIApplication + sendAction:to:from:forEvent • This is what gets called when
a wired up IBAction is triggered
to target: AnyObject? • “The object to receive the action
message. If to is nil, the app sends the message to the first responder, from whence it progresses up the responder chain until it is handled.” • First Responder in IB means target == nil
“…from whence it progresses up the responder chain until it
is handled.” • Initial receiver is the First Responder. • canPerformAction(_ action: Selector, withSender sender: AnyObject?) -> Bool • nextResponder() -> UIResponder?
None
Dismiss keyboard? • sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil
UITableViewCell • Works with UITableView to implement context menus. •
If you want to send an action via the responder chain, override canPerformAction:withSender:
Finding First Responder static __weak id currentFirstResponder; @implementation UIResponder (FirstResponder)
+ (id) currentFirstResponder { currentFirstResponder = nil; [[UIApplication sharedApplication] sendAction:@selector(findFirstResponder:) to:nil from:nil forEvent:nil]; return currentFirstResponder; } - (void) findFirstResponder:(id)sender { currentFirstResponder = self; } @end