Subclass does not have ivar of parents' public property

136 Views Asked by At

I'm learning objective-c and there is something I couldn't find an answer to.

I have declared a property in the public interface of a class. In that class I can access the ivar directly by using underscore, without synthesizing the property.

For example:
// Class.h @property (nonatomic, strong) NSString *someString; // Class.m _someString = something;

But if I subclass that class, I can access the setter and getter without any extra code, but I can't access the ivar directly, unless I explicitly synthesize the property, which was not necessary step in the superclass.

I know for a fact that it does create ivars specific for the subclass, because I have 2 subclasses of the same superclass, and each have their own values for the superclass's properties. I just don't understand why I need to explicitly synthesize the subclass if I want to access the ivars directly.

It isn't really a problem, but more of a curiosity.

0

There are 0 best solutions below