O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

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

Access Control

You do not always want elements of your program’s code to be visible to all other elements. In fact, you will frequently want to have much more granular control over your code’s access. You can grant components of your code specific levels of access to other components of your code. This is called access control.

For example, you might want to hide or expose a method on a class. Suppose you have a property that is used only within a class’s definition. It could be problematic if another, external type modified that property by mistake. With access control, you can manage the visibility of that property to hide it from other parts of the program. Doing so will encapsulate the property’s data and prevent external code ...

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