Ivars in Xcode Templates Prefixed with One or Two Underscores

Does anyone know why in Xcode templates (at least in Xcode 4.3.2) some ivars are prefixed with two underscores, and some with only one?

For example, the Master-Detail application template contains the MasterViewController.m file, where you can find:

@synthesize detailViewController = _detailViewController;
@synthesize fetchedResultsController = __fetchedResultsController;
@synthesize managedObjectContext = __managedObjectContext;

Thank.

+3
source share
1 answer

This is a small can of worms.

@synthesize, . , , (, ). , "foo" , "self.foo", . , .

Apple , . , . , , .

, . , , , ( ) ivars .

, . . , , . , "_" , .

, ? . . , .

, ? . "" ( ), ObjC, __block.

- . Apple , , . FWIW, ARC - , ARC, . FWIW, , Core Data. ( accessObjectContext):

__managedObjectContext = [[NSManagedObjectContext alloc] init];

__managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];

, , .

@synthesize foo = $foo;
@synthesize bar = bar$;

C/++ 25 , ObjC, . , . . , , , - , , , - . Xcode ( ).

, , , , , ...

+5

All Articles