这是&QUOT - →;"在目标C? [英] What is "->" in Objective C?

查看:113
本文介绍了这是&QUOT - →;"在目标C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了这个运营商弹出在例如code好几次在学在Mac上Objective C的。

I've seen this operator pop up quite a few times in example code in "Learn Objective C on the Mac."

我相信这是在目标C继承了C语言的操作员。
我想谷歌搜索和搜索堆栈溢出,并没有什么奇怪的来到了。

I believe it's an operator in the C language which Objective C inherits. I tried Googling and searching Stack Overflow and oddly nothing came up.

它有一个英文名字?

推荐答案

它与结构来做。

当我们在栈上有本地可用一个结构,我们访问其成员与运营商。例如:

When we have a struct available locally on the stack, we access its members with the . operator. For example:

CGPoint p = CGPointMake(42,42);
NSLog(@"%f", p.x);

不过,如果我们不是有一个的指针的一个结构,我们必须使用 - > 运营商:

However, if we instead have a pointer to a structure, we have to use the -> operator:

CGPoint *p = malloc(1*sizeof(CGPoint));
p->x = 42.0f;
NSLog(@"%f", p->x);
free(p);

这篇关于这是&QUOT - →;"在目标C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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