In XCode 4, when you create a new View-base-application project, here is the .h of the AppDelegate :
#import <UIKit/UIKit.h>
@class TestAppleProjectViewController;
@interface TestAppleProjectAppDelegate : NSObject <UIApplicationDelegate> {
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet TestAppleProjectViewController *viewController;
@end
And some items on the .m :
@implementation TestAppleProjectAppDelegate
@synthesize window=_window;
@synthesize viewController=_viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
I can see properties without vars…
I can see synthesize with var names that does not exist in the class…
I can see calls to those properties….
But… Where are the vars ?
Why such a code is working ?
Are there no more need to define vars into the class ? Are properties enough ?
In fact when you declare a var as a property, you don’t have to declare it again as var. The previous comportment where we had to declare it again was a bug in the previous versions of Xcode. And now it’s corrected.
It’s just an habit to take, less code duplicate and it’s good. (By default it’s creating ah hidden var with the same name beginning by “_”).