Now since Xcode 6 Beta 4 Swift got some nice access control features we know a bit from Java. Now you can declare Classes, methods, properties, structs or enums with public, private or internal.
- private entities are available only from within the source file where they are defined.
- internal entities are available to the entire module that includes the definition (e.g. an app or framework target). Default behavior when no keyword is used.
- public entities are intended for use as API, and can be accessed by any file that imports the module, e.g. as a framework used in several of your projects.
You can even declare the write access to private but expose the read access.
This gives us more control we knew from Objective-C with read only public properties or exposed methods in the header file.
See more and examples here at Apple’s Swift Blog