views:

94

answers:

2

Hi, I'm brand new to iphone dev, but am familiar with the MVC pattern. Can anyone please explain why the GLPaint sample class PaintingView.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.

+1  A: 

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.

Jasarien
A: 

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%5Fref/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.

Max