What does underscore in a member variable name mean in Objective-C?

Possible duplicate:
An underscore property name prefix in Objective-C

I am a C / C ++ developer and am learning Objective-C. I recently started with a tutorial that I found online. The code is as follows:

@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 someone explain to me the meaning of the statement

 @synthesize coordinate=_coordinate; 

I know the meaning of @synthesize . But he could not understand the complete statement. _coordinate is a member variable. But what is coordinate ? Where is it announced?

0
source share
1 answer

Basically, this means nothing to the compiler. This is just a coding practice used for private instance variables. Your code will not break if you do not use it.

+4
source

All Articles