iphone - Difference between _property and self.property -
i'm confused proper conventions when dealing properties. i'll illustrate question through example. example below know functionally "self.loan = self.loan + 250.00;" same "_loan = _loan + 250.00;" or not? see numerous tutorials on web may or may not use both methods access property. difference between using _loan , self.loan (i know self.loan same [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 _loan = _loan + 250.00; // exhibit b }
_loan variable , assigning value has no particular side effect.
self.loan = self.loan + 250.00 same writing [self setloan:[self loan] + 250.00] in methods called may other things set or value of variable. things methods depend on whether write custom versions of them (the setters , getters) or use @synthesize create them and, if use @synthesize, attributes apply in @property declaration.
Comments
Post a Comment