The @synthesize directive is a shorthand for creating access methods and ivar according to the specifications (atomicity, memory management) of a property with the same name. Given that re-synthesizing a property in a subclass (without re-declaring it) works just like redefining access methods - subclasses are used instead of the subclass. Since implementations are created by the compiler in both cases, there is no noticeable difference in behavior.
The only difference is that the synthesized Ivar has the same visibility as @private Ivar, so subclasses cannot access it, including to use it as a base variable for a property. This means that the re-synthesis in the subclass must use a different ivar name. If the superclass has @synthesize wildHorses = wildHorses_; , then the compiler requires the subclass to do something like @synthesize wildHorses = equusFerus; . *
* If the superclass uses the default name for the created ivar, @synthesize wildHorses; , then the subclass should still synthesize the new variable: @synthesize wildHorses = wildHorses_;
Josh caswell
source share