Just picking up Objective-C 2.0 and wanted to know if there is any advantage in using the dot operator for accessing properties instead of the "old" way. Short example of what I mean.
"old" way:
[myFraction setNumerator: 1];
[myFraction setDenominator: 3];
"new" way:
myFraction.numerator = 1;
myFraction.denominator = 3;
Thanks!
Rodrigo
The only difference is ease of typing and readability. The opinion of which is more readable differs from person to person :)
I use the dot syntax when I'm descending an object and use the bracket to actually set a property.
Like so:
[self.view setFrame:CGRectMake(0, 0, 320, 480)];
Instead of:
[[self view] setFrame:CGRectMake(0, 0, 320, 480)];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With