I have noticed that with Xcode4 Apple has updated the application templates to include underscores before instance variables.
// Xcode4
@property (nonatomic, retain) IBOutlet UIWindow *window;
@synthesize window = _window;
.
// Xcode3
@property (nonatomic, retain) IBOutlet UIWindow *window;
@synthesize window;
I know there are differing opinions on the usefulness of this but I was just curious if the updated templates where:
- (1) Highlighting a new best practice.
- (2) Showing how Apple does things but meaning for you to do it the old way.
- (3) Its just personal taste, it does not matter.
It's interesting because in the past (pre-iOS), Apple used to discourage the use of underscore prefixes for ivars:
But with a modern Objective-C runtime, I believe ivar naming conflicts in subclasses has been eliminated, so this is not a problem anymore. So I think that's why they're making the templates use an underscore prefix by default, to match what Apple's internal code looks like.