Skip to content

Conversation

@davelyon
Copy link
Owner

I would like to make adding Cheat Codes as seamless as possible for existing apps, and require minimal additional work. To that end, this pull request is one possible solution to enabling any arbitrary viewcontroller to get help output and avoid having to directly use UIKeyCommand for debug work.

To opt in, your UIViewController subclass:

  • Conforms to CheatCodeResponder
public protocol CheatCodeResponder: CustomDebugStringConvertible {
    var cheatCodes: [CheatCodeCommand] { get }
}
  • Calls addCheatCodes() in viewDidLoad to have the UIKeyCommands registered behind the scenes.

In order for the help method to find all CheatCodes in the current responder chain, I'm using _deepestUnambiguousResponder on UIWindow to find the bottom of the responder chain, and then walking back upward myself to print out the chained commands.

@davelyon davelyon changed the title Experimental first pass at viewcontroller support Experimental first pass at UIViewController support Sep 28, 2016
Update documentation and make 0.3.0 release ready
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant