Reputation: 5698
How to implement Child's delegates in Parent?
Parent.h:
@interface Parent : NSObject
Child.h
#import "Parent.h"
@protocol ChildDelegate <NSObject>
- (void)someMethod;
@end
@interface Child : Parent
I cannot declare Parent's interface to be:
@interface Parent : NSObject<ChildDelegate>
since it need to import "Child.h"
and it will be circular import.
How can i solve this?
Upvotes: 0
Views: 139
Reputation: 1096
You should declare protocol conformance in source files (with .m
extension).
You can declare Parent
class in Parent.h
without conformance to ChildDelegate
protocol.
@interface Parent : NSObject
And in your Parent.m
file you can write something as following.
#import "Child.h"
@interface Parent() <ChildDelegate>
@end
@implementation Parent
// Your implementation code here
@end
Upvotes: 1