Making a private setter and public getter simultaneously.

As I was stumbling upon not being able to access an object that belongs to an external framework that I created. I nearly spent half of my day trying to figure out what might be causing this. I then realized later that a Swift property could be declared using both private and public accessor level declaration. Here’s how you do that:

property declaration with two accessor levels

The above means that myProperty is only settable in the current object where it’s declared. However, it is accessible everywhere inside and outside the current framework.

--

--