Introducing the iOS Responder Chain

Introducing the iOS Responder Chain

Presented at Brisbane Cocoaheads, October 2015

lachlanroche

October 06, 2015

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

10 slides
  1. 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
  2. “…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?
  3. UITableViewCell • Works with UITableView to implement context menus. •

    If you want to send an action via the responder chain, override canPerformAction:withSender:
  4. 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

More Decks by lachlanroche

Other Decks in Programming