UIKeyCommand

I stumbled across a little gem today called UIKeyCommand. UIKeyCommand lets any UIResponder handle keyboard shortcuts that perform actions in your app. I used it to perform actions in a handful of view controllers. This is awesome for moving through an app quickly in development and is a big win for users as well.

To get started, make sure you are in a class that inherits from UIResponder. Next make sure that you can become the first responder:

- (BOOL)canBecomeFirstResponder {
    return YES;
}

Next, implement the keyCommands method defined in UIResponder.h:

- (NSArray *)keyCommands {
    return @[
        [UIKeyCommand keyCommandWithInput:@"+" modifierFlags:0 action:@selector(showPhotoPicker)],
        [UIKeyCommand keyCommandWithInput:UIKeyInputEscape modifierFlags:0 action:@selector(hidePhotoPicker)]
    ];
}

I can move through my app super fast now, and power users will certainly find shortcut support handy.