Swift Support 5 types of Access specifiers.
1. public
When we use public that class we can use outside of the module, but we can’t subclass that one outside of the module.
The module is like one project app/framework.
2. open
When we use open that class can be subclassed outside of the module. For example Apples UITableView we can subclass and use, i.e is defined in UIKit framework.
3. private
If we declare as private that function can be used in same class or extension of it, from swift 4 on-words. But you can’t use another class extension in the same file, their fileprivate can help.
4. fileprivate
If we say fileprivate that can be used entire file and even different class extension of in that file.
5. internal
By default, if we won’t specify any AccessSpecifiers it will be internal.
Note:
- internal class/ methods you can’t use outside of the module, where public you can use but can’t subclass. If you want all this functionality we can use open.
- private we can use in the same class extension if you want to use the different class extension in the same file go with fileprivate.