Initialisation of a CGPoint with { } notation
Asked Answered
A

1

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?

Anadiplosis answered 26/4, 2012 at 14:53 Comment(0)
A
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?.

Astroid answered 26/4, 2012 at 14:57 Comment(1)
Do you think struct initialization will work faster than CGPointMake function call?Secretarygeneral

© 2022 - 2024 — McMap. All rights reserved.