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
45
Xcode build script tips
lachlanroche
0
65
Introducing Datomic
lachlanroche
0
52
Introducing Xamarin
lachlanroche
0
57
Other Decks in Programming
See All in Programming
SwiftUI API Design Lessons
niw
1
270
これだけは知っておきたいクラス設計の基礎知識 version 2
masuda220
PRO
24
6.3k
RuboCop: Modularity and AST Insights
koic
1
170
AWSで雰囲気でつくる! VRChatの写真変換ピタゴラスイッチ
anatofuz
0
150
Making TCPSocket.new "Happy"!
coe401_
1
240
Strategic Design (DDD)for the Frontend @DDD Meetup Stuttgart
manfredsteyer
PRO
0
120
AWS で実現する安全な AI エージェントの作り方 〜 Bedrock Engineer の実装例を添えて 〜 / how-to-build-secure-ai-agents
gawa
8
750
The Evolution of the CRuby Build System
kateinoigakukun
0
130
Coding Experience Cpp vs Csharp - meetup app osaka@9
harukasao
0
740
Ruby's Line Breaks
yui_knk
2
700
技術選定を未来に繋いで活用していく
sakito
3
110
サービスクラスのありがたみを発見したときの思い出 #phpcon_odawara
77web
4
630
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Pragmatic Product Professional
lauravandoore
33
6.5k
Into the Great Unknown - MozCon
thekraken
37
1.7k
Testing 201, or: Great Expectations
jmmastey
42
7.4k
RailsConf 2023
tenderlove
30
1.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
5
530
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Being A Developer After 40
akosma
91
590k
The Cult of Friendly URLs
andyhume
78
6.3k
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