开发者

'logic' in view or view controller?

I aam planning to write a lcd numeric / 7 segment display for iphone.

(a display that consists of several numbers, each consisting of 7 (dash) segments.)

  1. My question is, after mvc pattern, where does the 'number parsing' code belong? View or its controller?

So, should the controller pass the view just a number to display, letting the -drawRect method find out which segments to lighten up?

Or should the controller pass the view directly, which segments to lighten up, after findi开发者_JAVA百科ng that out in a method within the controller class?

As i learned so far, the controller is responsible for all logic things. But i'm not sure if that kind of logic is also meant by that.

  1. Oh and by the way, should the controller just set properties on the view, or would it be better to call the controller as a delegate from within the view class to fetch the data?


I would say that the view should be figuring out which segments to draw. Ideally, you would be able to turn your app into an analog clock by just swapping out the view (since the numbers delivered from the controller wouldn't change.) While you don't want your view performing business logic, "visual" logic (how data should be drawn) is definitely within the purview of the view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜