Re: Difference between NSPoint, NSSize, NSRect and the CG Versions


Thanks a lot Quincey and Jens for your through explanation - I had imported some Mac code from another project which uses NSRect’s and as my original project was iOS this caused compile errors, so rather than trying to handle both sets, I’ll just use the CG versions from now on.

There are a few calls to NSInsetRect, NSOffsetRect, etc., too, I’m guessing these can just be replaced with the CG version too.

Thanks again
All the Best

On 1 Sep 2017, at 01:11, Quincey Morris <quinceymorris@...> wrote:

On Aug 31, 2017, at 14:07 , Steve Christensen <punster@...> wrote:

Regarding NSPoint, I see it defined as

typedef CGPoint NSPoint;

so its x and y fields will be CGFloats.

Opening up a macOS project and looking at the definition of NSPoint, I see:


typedef CGPoint NSPoint;


typedef struct _NSPoint {
    CGFloat x;
    CGFloat y;
} NSPoint;


So, it was the same size as CGPoint, but a different struct name, which was enough to create an ABI incompatibility. You could opt into the new typedef for 32-bit by using NS_BUILD_32_LIKE_64.

Join to automatically receive all group messages.