What does an underscore signify in the name of a member variable in Objective-C? [duplicate]
Possible Duplicate:
Prefixing property names with an underscore in Objective C
I am a C/C++ developer and am learning Objective-C. Recently I started on a tutorial that I found on net. The code is as below:
@interface MapDemoAnnotation : NSObject <MKAnnotation> {
CLLocationCoordinate2D _coordinate;
}
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate;
@end
@implementation MapDemoAnnotation
@synthesize coordinate=_coordinate;
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate {
self = [super init];
if (self != nil) {
_coordinate = coordinate;
}
return self;
}
@end
Can anyone please explain me the meaning of the statement
@synthesize coordinate=_coordinate;
I know the meaning of @synthesize
. But could not understand the complete statement.
_coordinate
is a member variable. But what is coordinate
? Where is it declared?
Basically, it doesn't mean anything to the compiler. It's just a coding practice used on private instance variables. Your code isn't going to break if you don't use it.