The ivar that is used for a property (which is gotten and set by the automatically synthesized property accessor methods) is named _<propertyName>
(i.e. the ivar's name is the property's name prefixed with an underscore).
In this case the property name is delegate
, so the the ivar that is used is _delegate
. This is already happening in your code. When you call -delegate
and -setDelegate:
, this ivar _delegate
will be gotten and set.
However, you've also declared your own ivar delegate
. Of course, the ivar you explicitly declared (delegate
) will not be gotten and set by the instance methods -delegate
and -setDelegate:
since the automatically synthesized ivar (_delegate
) is being gotten and set. However, (almost always--if it wasn't, your code is ambiguous) your intent was for your ivar delegate
to be the thing that your property's accessors would get and set. Luckily, the compiler is clever enough to notice what you've done, and that's why it is emitting this warning:
warning: autosynthesized property '
delegate
' will use synthesized instance variable '_delegate
', not existing instance variable 'delegate
' [-Wobjc-autosynthesis-property-ivar-name-match
]