typedef struct _NSPoint
{
float x;
float y;
} NSPoint;
So, to access the x and y coordinates of a
NSPoint called myPoint, you just do as in
myPoint.x and myPoint.y. Please note that the
coordinates of a NSPoint are floats; so, they might be
negative and/or fractionary.
To create a point with given x and y coordinates, you can use the function (macro) NSMakePoint (), as in the following example:
NSPoint testPoint; testPoint = NSMakePoint (10, 20); NSLog (@"x coordinate: %f", testPoint.x); // 10 NSLog (@"y coordinate: %f", testPoint.y); // 20
It might be worth quoting the (predefined) constant NSZeroPoint, which is a point with zero x coordinate and zero y coordinate.