Swift 4— Access Control
Access control restricts access to parts of your code from code in other source files and modules. This feature enables you to hide the implementation details of your code, and to specify a preferred interface through which that code can be accessed and used. You can assign specific access levels to individual types (classes, structures, and enumerations), as well as to properties, methods, initializers, and subscripts belonging to those types. Protocols can be restricted to a certain context, as can global constants, variables, and functions. In Swift 3 and swift 4, we have open , public , internal , fileprivate , and private for access control.Open access is the highest (least restrictive) access level and private access is the lowest (most restrictive) access level. As of Swift 4 , there are 5 levels of access , described below from the highest (least restrictive) to the lowest (most restrictive). 1. open and public — (least restrictive) Enable an entity t