Graphics Programs Reference
In-Depth Information
Dot Syntax
We should mention an alternative syntax for sending accessor messages to an object called
dot syntax:
// Following two lines are exactly equivalent
int value = [item valueInDollars];
int value = item.valueInDollars;
// Following two lines are exactly equivalent
[item setValueInDollars:5];
item.valueInDollars = 5;
We have reservations about Objective-C newcomers using dot syntax. We think it hides the
fact that you are actually sending a message and can be confusing. Once you are comfort-
able with Objective-C, it is totally okay to use dot syntax. But while you are learning, it's
better to use square brackets to make sure you understand what is really going on.
This topic will always use square brackets for sending accessor messages.
Search WWH ::




Custom Search