Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 553
Danyal Aytekin Avatar asked Apr 26 '12 14:04

Danyal Aytekin


1 Answers

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?.

like image 136
Hailei Avatar answered Sep 20 '22 15:09

Hailei