开发者

Why CGSize doesn't use * when declaring variables?

开发者 https://www.devze.com 2023-03-28 02:37 出处:网络
When I create an instance of a class called, say, Sprite, I do something like: Sprite *mySprite = [[Sprite alloc]开发者_JS百科init];

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

Sprite *mySprite = [[Sprite alloc]开发者_JS百科init];

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


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

精彩评论

暂无评论...
验证码 换一张
取 消