W1528 Private Means Private
Prerequisites[edit]
Background[edit]
Access control is used to restrict access to an entity in an effort to enforce users of your code (clients) to utilize it through a (hopefully) well-planned, well-defined, and well-implemented interface rather than through direct access to all properties and methods. Limiting access is a useful tool to implement information hiding, with the goal of enabling clients to more easily use the entity while simultaneously enabling resilience (stability of the code base in response to isolated changes in an implementation).
Introduction[edit]
Swift defines access control relative to modules and source files. A module is a unit of code distribution and can be imported using the import (for example Igis and Scenes. A source file is a single Swift source code file within the module.
Access Levels[edit]
Swift provides five different access levels for entities:
Keyword | Access Limitation |
---|---|
private | enclosing declaration only + extensions of declaration in same file |
fileprivate | same file |
internal | same module |
public | unlimited use |
open | unlimited use + subclass outside module + override outside module |