If you have a property in your public interface like the following
@interface MyClass : NSObject
@property(strong) NSString *myProp;
@end
And then synthesize it, in effect synthesizing the variable:
@implementation MyClass
@synthesize myProp = _myProp; // or just leave it at the default name..
@end
What is the visibility of the instance variable _myProp
? That is, is this considered @public
, @protected
or @private
? I'm guessing since MySubClass
could inherit from MyClass
then it would also get the properties (naturally), but would it also inherit the instance variable visibility?
What difference does it make if I put the property in a class extension? That would hide the property from subclasses, and I'm guessing the instance variable, too. Is this documented anywhere?
See Question&Answers more detail:os