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
130
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
130
Xcode keyboard tips
lachlanroche
1
39
Xcode build script tips
lachlanroche
0
60
Introducing Datomic
lachlanroche
0
49
Introducing Xamarin
lachlanroche
0
49
Other Decks in Programming
See All in Programming
Komplexe Oberflächen mit SVG und der Web Animation API
joergneumann
0
680
Elm Form Validation
bkuhlmann
0
510
CDKコントリビュートの最初の壁を越えよう! -簡単issueの見つけ方-
badmintoncryer
1
100
PostmanでAPIの動作確認が楽になった話
h455h1
0
170
2 週間で Twitter Bot を作ってみた
contour_gara
0
610
PHPはいつから死んでいるかの調査
chiroruxx
1
400
MicrosoftのPlatform Engineeringガイドを読んで実際になにかやってみた
ymd65536
1
400
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
850
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
500
サイコロで理解する統計的仮説検定の考え方
tatamiya
4
960
AmperとFleetを使ったAndroidアプリ
yoppie
0
170
Site Reliability Engineering for GMO
pyama86
8
1k
Featured
See All Featured
In The Pink: A Labor of Love
frogandcode
138
21k
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
Designing with Data
zakiwarfel
96
4.8k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
Debugging Ruby Performance
tmm1
70
11k
Six Lessons from altMBA
skipperchong
21
3k
Code Reviewing Like a Champion
maltzj
514
39k
Rails Girls Zürich Keynote
gr2m
91
13k
Statistics for Hackers
jakevdp
789
220k
Producing Creativity
orderedlist
PRO
337
39k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
125
32k
Web development in the modern age
philhawksworth
202
10k
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