Skip to content

Instantly share code, notes, and snippets.

@LearnCocos2D
Created January 19, 2013 00:02
Show Gist options
  • Save LearnCocos2D/4569727 to your computer and use it in GitHub Desktop.
Save LearnCocos2D/4569727 to your computer and use it in GitHub Desktop.
Initializer object demo. Instead of initializers with dozens of variants of "initWith…" methods, KoboldTouch makes heavy use of initializer object. These are simple Objective-C classes consisting mainly of properties. They set sensible defaults so you only need to change the properties that have to be set, and those you want to change. Then init…
// set menu options with the initializer object
KTTextMenu* textMenu = [KTTextMenu menuWithTextMenuItems:[NSArray arrayWithObjects:item1, item2, nil]];
textMenu.fontName = @"Arial";
textMenu.fontSize = 48;
textMenu.padding = 16;
// init the menu with the initializer object
KTMenuViewController* menuViewController = [KTMenuViewController menuControllerWithTextMenu:textMenu];
[self addSubController:menuViewController];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment