What is the difference between these two lines of code? They both work and both do the same, but is there any reason why one is preferable to the other, and if so why?
[textLabel setAlpha:0];
textLabel.alpha=0;
What is the difference between these two lines of code? They both work and both do the same, but is there any reason why one is preferable to the other, and if so why?
[textLabel setAlpha:0];
textLabel.alpha=0;
Using the ".alpha
" property calls the setter, which is "setAlpha:
", so ultimately you're calling the exact same code.
It's just a style difference and/or a preference for you.
There is no difference. The compiler translates
textLabel.alpha = 0;
into
[textLabel setAlpha:0];
However, some people prefer to use the "dot notation" only with properties, even if the language does not impose this restriction.