Swift provides different accessibility levels to codes. They include private
, fileprivate
, internal
, public
and open
. This feature can restrict other developer from accessing, extending and overriding the creator’s implementation. It is useful when a framework/ library is created and shared among different developers.
Before start, it is necessary to have a clear understanding on what a module
is. Module is an individual unit of code distribution, e.g. your app and 3rd party that is installed through CocoaPods
.
open
and public
are used to declare code accessibility level across different modules. internal
, fileprivate
and private
are used at the Swift file level.
private
means the declared code (class
, struct
, enum
, property
and method
, etc) can only be accessed within the current enclosing type.
extension
scope can only access those private properties only when it is declared at the same file of the extended class
, struct
and enum
.
#ios-app-development #ios #access-control #ios-development #swift-programming