More of a programming nerd than is strictly healthy. See also {,, twitter}


nevyn's blog

I had completely forgotten about nil targeted actions. BigZaphod reminds me of the canonical way of dismissing the keyboard:

[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];

The responder chain is so under-used in iOS. I’ll definitely try to think of ways to solve problems using it in the future.

For those of you who haven’t coded for the Mac, nil-targeted actions are what makes menus (among many things) work. When you select “Copy” from the menu, this is sent to the first responder. If that happens to be a text field, that text field gets the chance to put things into the clipboard. If it had been a check box, the check box would have no idea how to copy. However, that check box might be in a window, which belongs to a NSDocumentController, and the document might have the concept of copying the document as a whole. The app would step through the responder chain for you, from the check box all the way to the document controller, and perform the copy. Magic!

  1. millenomi reblogged this from nevyn
  2. i0sdev reblogged this from nevyn
  3. nevyn posted this