Skip to content

Instantly share code, notes, and snippets.

@plam4u
Last active January 10, 2017 18:32
Show Gist options
  • Save plam4u/c8d7ad78a8243f694359 to your computer and use it in GitHub Desktop.
Save plam4u/c8d7ad78a8243f694359 to your computer and use it in GitHub Desktop.
Debugging via keyboard shortcuts.return array of UIKeyCommand objects, which define a keyboard shortcut.The ViewController will execute corresponding actions mapped to the shortcut.Useful when you want to simulate interactivity but the UI is not ready yet or when you just need to do some debug work.
- (BOOL)canBecomeFirstResponder
{
return YES;
}
-(NSArray *)keyCommands
{
return @[
[UIKeyCommand keyCommandWithInput:@"1" modifierFlags:0 action:@selector(debugCommand1)],
[UIKeyCommand keyCommandWithInput:@"2" modifierFlags:0 action:@selector(debugCommand2)]
];
}
-(void)debugCommand1
{
NSLog(@"debugCommand1");
}
-(void)debugCommand2
{
NSLog(@"debugCommand2");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment