ios - synthesizing properties with trailing underscore -
this question has answer here:
i'm following along lynda.com ocunit testing tutorial uses xcode 4. in 1 of demos, synthesizes properties in location.m file this
#import "location.h" @implementation location @synthesize locationmanager=locationmanager_; @synthesize speed=speed_; the properties have trailing underscore. in other tutorials i've followed (such stanford ios class), synthesized properties prefixed underscore instance variables.
when properties created in .h file, there no underscores.
@property (nonatomic, strong) cllocationmanager *locationmanager; @property float speed; why trailing underscore in synthesize statement?
by writing
@synthesize locationmanager=locationmanager_; you defining ivar locationmanager_which backs property.
so, property still refer using
self.locationmanager however, ivar, "behind" property called: locationmanager_
Comments
Post a Comment