A Point Class and Object Allocation

The Rectangle class stores only the rectangle’s dimensions. In a real-world graphical application, you might need to keep track of all sorts of additional information, such as the rectangle’s fill color, line color, location (origin) inside a window, and so on. You can easily extend your class to do this. For now, let’s deal with the idea of the rectangle’s origin. Assume that the origin means the location of the rectangle’s lower-left corner within some Cartesian coordinate system (x, y). If you were writing a drawing application, this point might represent the location of the rectangle inside a window, as depicted in Figure 8.4.

Figure 8.4 A rectangle drawn in a window

In Figure 8.4, the rectangle’s origin ...

Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.