Reputation: 1542
I have a class A
that has an instance variable NSMutableArray *_onlyVisibleToSubclassesArray
. I would like to grant subclass B
access to this variable but not any other class C
which does not subclass A
.
Upvotes: 1
Views: 690
Reputation: 237030
This is what @protected
is, which is the default. Just declare an instance variable in the interface and it will be visible to subclasses and not to sibling classes.
Upvotes: 2
Reputation: 1542
A.h
@interface A : NSObject {
NSMutableArray *_onlyVisibleToSubclassesArray
}
B.h
#import "A.h"
@interface B : A
In B.m
I have access to _onlyVisibleToSubclassesArray
Another class C
that imports A.h
, cannot access _onlyVisibleToSubclassesArray
Upvotes: 0