Search code examples
objective-cterminologyinstance-variablesdeclared-property

What does "back" mean in the context of Objective-C declared properties?


Reading some Objective-C manuals about properties and instance variables, I came across a lot of sentences like

a readwrite property will be backed by an instance variable.

or

Properties are typically backed by an instance variable with a leading underscore, so creating a property called firstName would have a backing instance variable with the name _firstName

What is a "backing" variable? Why does the text use the word "back"? What does it mean exactly?


Solution

  • In the context of implementing properties of Objective-C classes the word "back" means "providing a storage for property's value".

    In a sense, the word "back" is opposite of the word "front": the methods implementing the property's getters and setters provide a "front" through which the users of the class interact with the property, while the variable provides the "back" place for the methods to store the value.