What does -> mean?

前端 未结 5 917
太阳男子
太阳男子 2021-01-12 13:03

I\'m a relative newbie to Objective-C (only studied Arron Hillegras\'s book) and am confused by the following snippit of code I\'ve found in one of Apple\'s code examples, i

5条回答
  •  臣服心动
    2021-01-12 14:02

    It's an operator which roots from C Programming Language. And since Objective-C is compatible with C programming, you may see developers using traditional C-style programming.

    "->" is used to access a elements of a pointer. And since the "objects" in Objective-C are just pointers (denoted by *), e.g. NSNumber *number; , you can use this notation to access their elements.

    I never used this notation in Objective-C since the dot notation in Objective-C is accepted. If "self" has a synthesized property "number" then self.number should be the same as self->number (this is true ONLY in Objective-C.

提交回复
热议问题