i've worked with delegation before. i know how to create delegation from a superview to a subview class. however, i'm trying to do it the opposite way using the same approach but it's not working! is delegation meant only to work one way or is there a way/trick to use it as a two way communication between the classes? I'm receiving an error at the parent/superview .h class which is:
Cannot find protocol definition for 'SubViewControllerDelegate'
my code goes like this: subview.h
#import <UIKit/UIKit.h>
#import "SuperViewController.h"
@protocol SubViewControllerDelegate <NSObject>
- (void)someMethod:(NSData *)data;
@end
@interface SubViewController : UIViewController
@property (weak, nonatomic) id <SubViewControllerDelegate> delegate;
@end
subview.m:
[self.delegate someMethod:data];
SuperView.h
#import <UIKit/UIKit.h>
#import "SubViewController.h"
@interface SuperViewController : UIViewController <SubViewControllerDelegate>
@end
SuperView.m:
#pragma mark - SubView Controller Delegate Methods
- (void)someMethod:(NSData *)data{
NSLog(@"%@", data);
}
am i doing anything wrong or missing out anything?