many Places in the sample code i have seen 2 different way of @synthesize variable. For Example here i am taking 1 sample button.
@property (strong, nonatomic) IBOutlet UIButton *logonButton;
1.@synthesize logonButton = _logonButton;
2.@synthesize logonButton;
among this 2 methods which one is recommended?
Short Answer
The first method is preferred.
Long Answer
The first example is declaring that the generated ivar for the
logonButtonproperty should be_logonButtoninstead of the default generated ivar which would have the same name as the property (logonButton).The purpose of this is to help prevent memory issues. It’s possible that you would accidentally assign an object to your ivar instead of your property, and it would then not be retained which could potentially lead to your application crashing.
Example