objective c - Obj-C editor with a bad MVC pattern, how to clean this up? -
i've been working on game engine in obj-c , decided build editor in obj-c. how i've done now, rid of "glue code" , follow "best practises". time being spent on "glue code" , code base getting large maintain objects depending on each other , keeping referances. typical old-school scenario :-)
the view contains lot of options i.e. checkboxes, sliders & textfields.
1) when "stars" number changed 2000, action sent controller.
2) controller verifies input, numeric textfields have number formatter text input file names or other names input verified running code check if name valid.
3) number stars (2000) sent next layer, game engine scene (which has starfield object member).
4) game engine scene applies new amount of stars starfield object member.
*) if number of stars changes inside of game engine scene or starfield object, call made controller updates ui textfield.
how can make right , more efficient, rid of glue code options can set yet keep simple , clean? need modify game engine make work better editor , ui?
i think should aim this, think? use bindings, kvo etc. ?
example code: assume change number of stars in textfield , gets called.
// in controller class - (ibaction)starfieldamountchanged: (id)sender { const nsinteger numofstars = [sender integervalue]; [mgameenginetestscene setstarfieldamount: numofstars]; } // in game engine test scene class - (void)setstarfieldamount: (nsinteger)newamountofstars { [mstarfield setamountofstars: newamountofstars]; } - (nsinteger)getstarfieldamount { return [mstarfield getamountofstars]; }
thanks
Comments
Post a Comment