Saturn
Saturn

Reputation: 18149

Why CGSize doesn't use * when declaring variables?

When I create an instance of a class called, say, Sprite, I do something like:

Sprite *mySprite = [[Sprite alloc]init];

But why when creating a CGSize or int type variable, I can't use *? Basically, what's the * for?

Upvotes: 5

Views: 874

Answers (1)

Joe
Joe

Reputation: 57179

The * denotes a pointer. CGSize is declared as a struct and Sprite is a class, and in Objective-C all classes are referenced by a pointer.


You can find additional information in the Programming with Objective-C documentation. The relevant sections are Use Pointers to Keep Track of Objects and Methods Can Return Values.

Upvotes: 16

Related Questions