I have read in iOS Programming Fundamentals by Matt Neuberg that instance variables are protected, meaning that other classes, except for subclasses of this one, can't see them.
I have a parent class A where I define an ivar list. (A.m)
@interface A ()
@end
@implementation A
{
NSArray *list;
}
@end
Class B extends A (B.h)
#import "A.h"
@interface B:A
@end
(B.m)
@interface B ()
@end
@implementation B
list =
...
@end
I want to use ivar list in child class B but the compiler doesn't see that the was reference declared in the parent class. I have tried explicitly using @protected but that doesn't work. I don't want to expose ivar list on the public interface. It's an internal structure that is a common element of all subclasses. How can I do this?
@protected