What does -> mean?

前端 未结 5 918
太阳男子
太阳男子 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:05

    It's usually called the 'arrow' operator. It allows you to access the instance variables of an object (or of a struct) using a reference or pointer to the instance. It's common syntax with C and C++.

    I'm struggling to find a nice write up, but you might find this one informative.

    As to the underscore - commonly they mean "private"; according to the Coding Guidelines for Cocoa - Naming Basics:

    Avoid the use of the underscore character as a prefix meaning private, especially in methods. Apple reserves the use of this convention. Use by third parties could result in name-space collisions; they might unwittingly override an existing private method with one of their own, with disastrous consequences.

提交回复
热议问题