views:

72

answers:

1

Hi,

I'm slightly used as to what the purpose of CALayer's existence is. Why not just put the properties in a UIView?

Thanks.

+2  A: 

A CALayer represents a completely different "thing" from a UIView. A CALayer only deals with drawing itself, and encapsulating the information needed to do that. A view, on the other hand, owns one or many layers, which it uses to draw itself. A view has many other functions and properties though, that are unrelated to its representation on the screen.

I would recommend digging into the Apple documentation, and maybe picking up a book on Object Oriented coding.

DougW
Right, so why not just add the properties that the layer would have directly to the view?
jasonbogd
That's the whole point of object based coding. Objects should be responsible for well defined parts of behavior, and nothing else. What you're describing is a classic case of the "God Object", and is explicitly contrary to good object oriented design. http://en.wikipedia.org/wiki/God_object
DougW