O'Reilly logo

Cocoa Design Patterns by Donald A. Yacktman, Erik M. Buck

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10. Accessors

The Accessors pattern (also known as “setters and getters”) describes a technique for funneling all access to an object’s properties through well-defined and easy to recognize methods called accessors. Properties are often stored as instance variables but in some cases may be stored a different way or calculated as needed. The Accessors pattern maximizes implementation flexibility while minimizing opportunities for errors. The Accessors pattern provides the following benefits:

Implementation flexibility. Properties can be stored as instance variables or using other techniques such as the Associative Storage pattern, and the implementation can be changed without breaking other code.

Minimum maintenance burden. All uses of an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required