Sorry if this question has been asked before but there were literally no results when i typed it into google. As the title states, I would like to know what the ->
operator does. I see it everywhere: [self processTorrent:alert->handle];
but don't know what it does
Asked
Active
Viewed 199 times
-1

rmaddy
- 314,917
- 42
- 532
- 579

Mark Bourke
- 9,806
- 7
- 26
- 30
-
1See http://stackoverflow.com/questions/2575048/arrow-operator-usage-in-c – Itai Ferber Nov 28 '15 at 18:57
1 Answers
0
It's the structure dereference ("member b of object pointed to by a") in C. Objective-C is a strict superset of C.
The the usual way to access a member a is as s.a which, given the pointer, is expressed as (*p).a or can instead be accessed by the shorthand:
p->a using the structure dereference operator.
struct point
{
int* x;
int* y;
};
structure point* struct1;
As with any pointer. To change the address it points to:
struct1->x = &varX;
To change the value at the address to which it points:
*(struct1->x) = varX;

Alexander
- 159
- 7
-
3Why would `x` and `y` be pointers? That's confusing the answer since it's not relevant to the question. – rmaddy Nov 28 '15 at 19:02