In the latest Xcode @synthesize
is optional. By default, omitting @synthesize
is the same as writing
@synthesize someName = _someName;
The only reason to use @synthesize
is to rename the instance variable created to store the value of the property, for example
@synthesize someName = someSpecialName;
When you use self.variableName
to access a variable, you go through a property, which is a short method that accesses the instance variable for you. Although the method dispatch is very fast, it may perform additional services for you, such as synchronizing the access to the variable (this is the case when you specify atomic
or do not specify nonatomic
in the property declaration). In cases like that, the access through self.variableName
will be somewhat slower. If done in a tight loop, this could potentially make a difference. That is why you sometimes want to access the underlying instance variable directly by using _variableName
.