Swift offers 5 access modifiers: open
, public
, internal
, fileprivate
and private
.
Of what I know about these specifiers, (mainly from link & link_2)
open
means classes and class members can be subclassed and overridden both within and outside the defining module (target).
fileprivate
restricts the use of an entity to its defining source file. Basically accessible by multiple classes within a single file.
private
restricts the use of an entity to its enclosing declaration.
Now, public and internal seems pretty much the same to me :-
public
means classes and class members can only be subclassed and overridden within the defining module (target).
internal
enables an entity to be used within the defining module (target). Also, this happens to be the default specifier if nothing else is mentioned. We would typically use internal access when defining an app’s or a framework’s internal structure.
So basically how do public and internal differ?
This is my first Question here, so if I have missed out any details, please let me know. Thanks in advance.