开发者

iPhone GLPaint sample has architecture design flaw?

开发者 https://www.devze.com 2022-12-10 03:18 出处:网络
I\'m brand new to iphone dev, but am familiar with the MVC pattern.Can anyone please explain why the GLPaint sample class PaintingView.开发者_C百科m (the View) actually gets the data required from dis

I'm brand new to iphone dev, but am familiar with the MVC pattern. Can anyone please explain why the GLPaint sample class PaintingView.开发者_C百科m (the View) actually gets the data required from disk to write the "Shake Me!" text? The Data is the Model and should be read from the disk by the controller and passed to the View to render IMO. Correct?

Also, the Controller is adding UI controls to the view (color palette segmented control) - shouldn't the view be drawing this stuff?

Is this a bad example Apple have provided?

Thanks.


It's a good example of how to use OpenGL, but it's a poor example of MVC. I imagine that since MVC wasn't the focus of this example, it wasn't really written with it in mind.

At the end of the day, if the example works and shows you how to use the thing it's being an example of, then it's done its job.

I'm sure there are other examples of MVC out there from Apple that are done properly.


Thanks, I think it's a bit of a hack, but:

http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW8

Combining Roles One can merge the MVC roles played by an object, making an object, for example, fulfill both the controller and view roles—in which case, it would be called a view-controller. In the same way, you can also have model-controller objects. For some applications, combining roles like this is an acceptable design.

0

精彩评论

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