Objective-C property and synthesize logic

后端 未结 3 1099
天涯浪人
天涯浪人 2020-12-15 08:10

What is an actual name of instance variable, say, topSpeed, as from lectures of Stanford University about the Objective-C and iOS development?

Here is the code:

3条回答
  •  一向
    一向 (楼主)
    2020-12-15 08:36

    For the first question the answer is "naming convention". So it is only a naming convention. If you want to access the topSpeed variable, the "get" part is not significant - like [car topSpeed] is easier to read than [car getTopSpeed]. As for the second question, I am not sure but I believe you access the topSpeed property through the variable _topSpeed.

提交回复
热议问题