Well ! I got confused about the way of declaring variables & implementing its properties.
The .h File contents
@interface XYZAppDelegate : NSObject <UIApplicationDelegate> {
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet XYZViewController *viewController;
@end
The .m File Contents
#import "XYZAppDelegate.h"
#import "XYZViewController.h"
@implementation XYZAppDelegate
@synthesize window=_window;
@synthesize viewController=_viewController;
My questions/Queries are as follows.
- Don’t we require to declare variables if we put property ? ( Using property, we can indirectly declare variable – is it like that ? )
- What are the additional features other than this ? ( In coding specific )
- Why does everybody insist to use _ before each property accessor ? ( Other than security threats ? Has it become coding standard ? Whats the reason behind it? )
variable. It is done automatically,
I believe by @synthesize. One
advantage to declaring it is that the
debugger will automatically list it.
Weigh this against the ugliness of
redundant definition.
assigned (unretained) values.
naming member variables that are
differently named than properties and
method variables. Apple’s samples
sometimes use this convention and
sometimes do not. I view it as
usually unnecessarily verbose as a
programmer can easily tell the
difference between myVariable and
self.myVariable.