Its often confusing at first glance as to when you are using the getter/setter methods and when you are accessing the ivar directly.
The alternative is name the ivar differently from the property. A common approach is to use an underscore to prefix the ivars names, like so -
@interface RootViewController : UITableViewController
{
NSDate *_timestamp;
}
@property (nonatomic, retain) NSDate *timestamp;
To connect the property (whose name has not changed) the sythensize statement gets an extra option:
@implementation RootViewController
@synthesize timestamp = _timestamp;
Essentially, if an ObjectiveC programmer declares ivars following this convention (and they should) and uses the basic syntax @synthesize _window;
then the usage for the property becomes somewhat ugly: classInstance._window = myWindow
or [classInstance set_window:myWindow]
. Using the syntax @synthesize window=_window;
allows the Obj-C programmer to utilize a popular programming standard (preceding ivars with _
) while simultaneously having property accessors that use the Apple standard classInstance.window = myWindow
and [classInstance setWindow:myWindow]
.