In a recent Xcode 4.3 project template, some @synthesze are declared as:
@synthesize window = _window;
@synthesize managedObjectContext = __managedObjectContext;
@synthesize managedObjectModel = __managedObjectModel;
@synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
@synthesize navigationController = _navigationController;
Some come with a double underscore (__) as prefix. Why?
Anything to do with readonly attribute?
@property (strong, nonatomic) UIWindow *window;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (strong, nonatomic) UINavigationController *navigationController;
They probably shouldn’t use a double underscore, if they’re intended for use in your own program. I expect it’s just an oversight on the part of whoever wrote that template example. In practice, it’s unlikely that they’ll cause any problems.
The C standard reserves all identifiers starting with a double underscore for the implementation’s own use. Since Objective-C is a superset of C, you shouldn’t be using those identifiers in Objective-C programs either. From the C spec, section 7.1.3 Reserved identifiers: