Wednesday, August 1, 2012

Public, Private, and Protected Instance Variables

Classes can set instance variables as private, protected, and public. You use the compiler directives @private, @protected, and @public to declare the visiblity of instance variable.

The public directive allows any class access to the public variables.
The private directive ensures private variables are only visible to the class which declares it.
The protected directive ensures protected variables are only visible to the declaring class and its descendants.