Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

breaking down typedef structs in objective-c

So I'm currently learning obj-c and came across this code in a header file that's provided by apple in CGGeometry.h header file.

struct
CGPoint {
    CGFloat x;
    CGFloat y;
};
typedef struct CG_BOXABLE CGPoint CGPoint;

I don't understand the last portion of the code. This part:

typedef struct CG_BOXABLE CGPoint CGPoint;

So from my C days I remember defining a struct using typedef saves you from having to call it like so:

struct CGPoint{
}

And instead call it like this:

CGPoint{
}

But, what is the CG_BOXABLE and CGPoint? Is it like an inheritance thing or something? I'm referring to the first CGPoint.

like image 288
humbleCoder Avatar asked Apr 28 '26 14:04

humbleCoder


1 Answers

I believe it's a newly added feature, adding the ability to box the struct without having to add your own objc_boxable attributes.

See the radar that seemingly started this feature request: http://openradar.appspot.com/32486932

like image 103
dzl Avatar answered Apr 30 '26 07:04

dzl