Difference between _property and self.property

前端 未结 3 514
轻奢々
轻奢々 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 21:56

    _loan is a variable and assigning a value to it has no particular side effect.

    self.loan = self.loan + 250.00 is essentially the same as writing [self setLoan:[self loan] + 250.00] in that methods are called that may do other things than simply set or get the value of a variable. The extra things those methods do depend on whether you write custom versions of them (the setters and the getters) or use @synthesize to create them and, if you use @synthesize, what attributes you apply in the @property declaration.

提交回复
热议问题