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


Quincey Morris
 

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:

#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64

typedef CGPoint NSPoint;


#else

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


#endif

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 cocoa@apple-dev.groups.io to automatically receive all group messages.