Access Control in Swift

The 5 Access Levels In Swift

The default access level in Swift is internal .

You can use access control for function, class member, struct, enum, tuple, property or any other characteristic

Refer above image for access level hierarchy.

This would fail since variable a has more access than the class A
This would fail since the setter has more access than the property and its getter
An overridden function cannot be private.
solution: use private for tuple variable
solution: use private or fileprivate for function in class B or set class B as private

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store