为什么在声明变量时CGSize不使用*? [英] Why CGSize doesn't use * when declaring variables?

查看:114
本文介绍了为什么在声明变量时CGSize不使用*?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个名为Sprite的类的实例时,我会做类似的事情:

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

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

但是为什么在创建CGSize或int类型变量时不能使用*?基本上,*是做什么用的?

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

推荐答案

*表示指针. CGSize被声明为struct,而Sprite是一个类,并且在Objective-C中,所有类均由指针引用.

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.

这篇关于为什么在声明变量时CGSize不使用*?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆