objective c - iOS: On not duplicating the view hierarchy in the MVC model -
objective c - iOS: On not duplicating the view hierarchy in the MVC model -
this question related mvc (in ios programming), , book wherein author uses mvc differently have seen before.
i think have pretty clear understanding of apple's interpretation of mvc-pattern, explained in stanford's on-line course of study on ios programming. say, model , view should independent, , controller should deed glue in between.
i have implemented few ios applications view contains movable objects. in doing so, movable objects have been implemented sub-views (or calayer:s), , have been instantiated main view. sub-view knows own location , size (in frame property), info duplicated in model object. in fact, entire view hierarchy represented in model (and blame much of spagetti coding redundancy).
in book beginning ios game development author, patrick alessi, implements game called blocked (a.k.a breakout). in implementation, the model allocates , initializes array of uiview objects (the blocks in breakout game) , controller adds them view. when block later on should disappear, model removes superview array.
i have mixed feelings of alessi's implementation. avoids duplication of data! how relate mvc? inquire question broaden own understanding of mvc. possible regard uiview object both view , model object?
well it's game not info processing application. model closely tied view because care on screen blocks can calculate if beingness nail , on. same goes 3d shooters info concerns things have location somewhere in 3d space. create sure manage refactor out code doesn't straight involve drawing view out of uiview subclass.
things scoring, player info , ads should utilize traditional mvc model.
ios objective-c model-view-controller
Comments
Post a Comment