Why CGSize doesn't use * when declaring variables?

后端 未结 1 1976
春和景丽
春和景丽 2021-01-13 03:05

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

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

But why when creati

1条回答
  •  星月不相逢
    2021-01-13 03:33

    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.

    0 讨论(0)
提交回复
热议问题