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 ...
Get Swift Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.