I have a class that implements a protocol . In MyProtocol, I have two properties:
@protocol MyProtocol <NSObject>
@property(nonatomic, retain) NSObject *stuff;
@property(nonatomic, retain) NSString *stringStuff;
@end
My class implements the protocol as shown
Header .h
@interface MyClass : UIViewController <MyProtocol>
...
Implementation.m
@implementation MyClass
@synthesize stuff;
@synthesize stringStuff;
...
I have a class that inherits from MyClass…
@interface MySubClass : MyClass
When I try to access stuff and stringStuff in MySubClass, I get an error saying that MySubClass does not have a member named ‘stringStuff.’
How can I get the child classes to be able to access these members of the parent class?
You will need to use property access in the subclass, were you trying to access the ivars directly?
Edit: Just realised I didn’t answer your original question. Yes, if a superclass implements a protocol then the subclass will too.