What does objc's -> stand for ?
Is there any difference from just dot chain?
e.g. self.delegate , self->delegate
Asked
Active
Viewed 59 times
-2
-
1Dot syntax will go through the objc getter, that arrow syntax is used to simply access the raw ivar – SomeGuy Mar 19 '15 at 01:09
-
1You should know C/C++ before you tackle Objective-C. – Hot Licks Mar 19 '15 at 01:35
1 Answers
2
-> in Objective-C is the same as -> in C. It is a field access operator that lets you dereference a pointer (as opposed to dot . operator, which requires a struct).
What's confusing about it in Objective-C is the dot syntax on pointers for accessing properties. So the rules for choosing a dot vs. -> become a little confusing:
- Use dot
.for accessing Objective-C properties on Objective-C objects, which are always accessed through pointers - Use arrow
->for accessing Objective-C instance variables on Objective-C objects, and for accessing fields on C structures through pointers - Use dot
.for accessing fields on C structures.
Sergey Kalinichenko
- 714,442
- 84
- 1,110
- 1,523