I am trying to understand the purpose of the synthesize
directive with property name overriding. Say that I have an interface defined as follow:
Your understanding is incorrect. dummyLabel
is the name of the property, and is not an alias for the instance variable - the instance variable is only called _dummyLabel
. So the following holds for an instance of Dummy
called myObject
:
[myObject dummyLabel]
worksmyObject.dummyLabel
works[myObject _dummyLabel]
failsmyObject._dummyLabel
failsmyObject->dummyLabel
failsmyObject->_dummyLabel
depends on the visibility of the ivar (@public
, @private
, @protected
)[myObject valueForKey: @"dummyLabel"]
works[myObject valueForKey: @"_dummyLabel"]
depends on the implementation of +accessInstanceVariablesDirectly
(i.e. it will work in the default case where +accessInstanceVariablesDirectly
returns YES
).