user1628311
user1628311

Reputation: 176

What actually is a CGContextRef?

I've been searching around the documentation for the core graphics framework and came across this in the CGContext reference

typedef struct CGContext * CGContextRef;

What does this actually mean? Is it a pointer to a CGContext? Also when I had a look at CGColor the CGColorRef is like this:

typedef struct CGColor *CGColorRef;

What's the difference between the two?

Thanks for any help!

Upvotes: 0

Views: 382

Answers (2)

Anoop Vaidya
Anoop Vaidya

Reputation: 46533

CGContext and CGColor are two structures; the other two, CGContextRef and CGColorRef are their respective pointer types.

It's like typedef int* myIntegerPointer;

Just compare with: typedef CGContext* CGContextRef;

EDIT:

int* a, b is same as int *a, b .

* is associated only with a, not with b. So in this case space doesn't play anything.

Upvotes: 0

sradforth
sradforth

Reputation: 2186

Yes, they are just shortcuts to say a pointer to a CGContext or a CGColor.

So you can write

CGColorRef myreference;

rather than

CGColor *myreference;

Upvotes: 1

Related Questions