Difference between _property and self.property

前端 未结 3 513
轻奢々
轻奢々 2020-12-19 21:22

I\'m slightly confused as to the proper conventions when dealing with properties. I\'ll illustrate my question through an example. So from the example below I know that func

3条回答
  •  无人及你
    2020-12-19 22:04

    You should never use direct reference to a variable when accessing a property. Always go for self.property in your code.

    If you use _property you are not making use for your getters and setters. In this case you are just wasting @synthesize use.

    self.loan = self.loan + 250.00; //Exhibit A

    This should be right approach.

提交回复
热议问题