You are able to get/set the property, you just can't directly access the instance variable/backing store behind it, which you typically don't do anyway even when they belong to the subclass.
_x
is the instance variable or ivar.
self.x
is the property, accessed via getter/setter methods created when you use @property
to declare x
.
When you use @property
(previously used with @synthesize
, no longer required) it auto-generates the getter, setter, and backing ivar. The ivar itself, depending on where it's declared is created either as @protected
or @private
. Responses to this question, while a bit old, give some insight to the different visibility modifiers.
If you declare @property double x
in your public .h file, it will be @protected
by default, meaning that both the accessor methods and the ivar should be visible to instances of the superclass and subclasses, but not to instances of other outside classes.
If you declare that same @property
in a class extension or the @implementation
block in your .m (exposing only what you really need to), it's @private
by default, meaning the ivar is only accessible by instances of that exact class - not subclass instances. This leaves only the getter/setter methods exposed to the subclass.
You can override these defaults if you choose, but generally it's preferable to use accessor/mutator methods & not deal directly with ivars. This is by design, since you want to control exactly how other objects, even subclass instances, can access/manipulate your variables.