6

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?

Hailei
  • 42,163
  • 6
  • 44
  • 69
Danyal Aytekin
  • 4,106
  • 3
  • 36
  • 44

1 Answers1

10

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

Community
  • 1
  • 1
Hailei
  • 42,163
  • 6
  • 44
  • 69
  • Do you think struct initialization will work faster than `CGPointMake` function call? – k06a Jan 31 '17 at 18:11