Synthesized Accessor Methods
As of Objective-C 2.0, you can have your setter and getter methods (collectively known as accessor methods) automatically generated for you. We haven’t shown you how to do this up to this point because it was important for you to learn how to write these methods on your own. However, it’s a nice convenience provided in the language, so it’s time for you to learn how to take advantage of this feature.
The first step is to use the @property directive in your interface section to identify your properties. These properties are often named the same as your instance variables, although they don’t have to be. In the case of our Fraction class, the two instance variables numerator and denominator fall into this category. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access