문제

I've been trying to improve my "Objective-C" programming style, and I came across this article which talks about variables and setting values. It helped me clear up a lot of things, but I still have a question.

Jonathan Sterling mentions in his answer both

self.qux = blah;

and

[self setQux:blah];

Is there any difference between the two? If so, which one is the preferred coding style?
And I believe the correct term for the second example is getter and setter methods, but what is the first style called?

도움이 되었습니까?

해결책

They are both the same. You can use either of the style of the code. It is called as property. A property has both getter and setter.

For me,

For property, I will use self.myProperty.

When it is a method, I will use [self myMethod];

It is really depends on your programming style.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top