Objective-C 2.0 introduced a convenient syntax to simplify the process of getting and setting object values. This syntax is known as dot notation.
Imagine you created an Employee class and defined an instance of Employee with the name myEmployee. To refer to an Employee property, you might use a statement like this:
employeeAge = [myEmployee age];
This code sends the age message to the myEmployee instance which returns the current value of myEmplyee’s age property and sets employeeAge to that value.
Objective-C’s dot notation allows you to rephrase the above statement like so:
employeeAge = myEmployee.age;
The dot notation tells Objective-C to call the getter function (accessor) to retrieve age and set employeeAge to that value.
Similarly, you can use dot notation to access the setter function (mutator):
myEmployee.age = employeeAge;
Dot notation is pretty straightforward, but it has caused a bit of controversy in the Objective-C community. Apple has embraced dot notation and uses it frequently in official Cocoa and Cocoa Touch sample code.
Google, meanwhile, has banned the use of dot notation in their official code. Here’s a link to Google’s official Objective-C Style Guide.
So what should you do? Use dot notation? Run away from it screaming? Shun those who do use it?
Best thing to do is to read Jeff LaMarche’s cogent analysis of Google’s ban. Best take on dot notation you are likely to see, in my opinion. Jeff really knows his stuff. Take a read…