Danyal Aytekin
Danyal Aytekin

Reputation: 4215

Initialisation of a CGPoint with { } notation

After CGPointMake let me down I found out that we can initalise a static const CGPoint like this instead:

static const CGPoint p = { 0.f, 0.f };

It works but what is the curly bracket notation actually doing?

Upvotes: 6

Views: 3937

Answers (1)

Hailei
Hailei

Reputation: 42163

CGPoint is a struct:

struct CGPoint {
    CGFloat x;
    CGFloat y;
};

It's a valid method to initialize a struct in C. See Struct initialization of the C/C++ programming language?.

Upvotes: 10

Related Questions