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 functionally "self.loan = self.loan + 250.00;" is the same as "_loan = _loan + 250.00;" or is it not? I see numerous tutorials all over the web that may or may not use both methods to access a property. So what exactly is the difference between using _loan and self.loan (I know that self.loan is the same as [self setLoan:])
//ClassA.h
@interface ClassA: UIViewController
@property double loan;
@end
//ClassA.m
@implementation ClassA
@synthesize loan = _loan;
-(void)doSomething{
self.loan = self.loan + 250.00; //Exhibit A
_loan = _loan + 250.00; // Exhibit B
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…