Swift provides another set of tools that helps to control what code other code has access to called access controls. All code is actually given three levels of access control:
Before we can really discuss this further, you should understand completely what a module is. It is beyond the scope of this book to talk about implementing a module but a module is a collection of code that can be used in other modules and apps. So far, we have used the Foundation
module provided by Apple. A module is anything that you use when using the import
keyword.
All code, by default, is defined to be at the internal level. That means that any given piece of code in your program can access any piece of code defined in any other file that is also included in your program as long as it follows the scoping rules we have already discussed...