Next: 1.4 Geometry Functions Up: 1 Points, Sizes and Previous: 1.2 NSSize

1.3 NSRect

An NSRect is a struct describing both the position and the size of a rectangle:
typedef struct _NSRect
  NSPoint origin;
  NSSize size;
} NSRect;
Using NSRect is similar to using NSPoint and NSSize:
NSRect testRect;

testRect = NSMakeRect (8.1, -3, 10, 15);
NSLog (@"x origin: %f", testRect.origin.x); // 8.1
NSLog (@"y origin: %f", testRect.origin.y); // -3
NSLog (@"width: %f", testRect.size.width); // 10
NSLog (@"height: %f", testRect.size.height); // 15
Note that you first access the origin, and then its coordinates, and similarly for the size.

The constant NSZeroRect represents a rect with NSZeroPoint origin and NSZeroSize size.