I have defined a protocol in a separate file (myProtocol.h). Here is the code for it:
#import <Foundation/Foundation.h>
@protocol myProtocol <NSObject>
-(void) loadDataComplete;
@end
Now I want to call this method so I have done the following code:
firstViewController.h:
#import "myProtocol.h"
@interface firstViewController : UIViewController{
id <myProtocol> delegate;
}
@property (retain) id delegate;
-(void) mymethod;
firstViewController.m
@implementation firstViewController
@synthesize delegate;
- (void)viewDidLoad {
[self mymethod];
}
-(void) mymethod {
//some code here...
[delegate loadDataComplete];
}
I have another file where the protocol is also utilized:
secondViewController.h:
#import "myProtocol.h"
@interface secondViewController : UIViewController<myProtocol>{
}
secondViewController.m:
-(void) loadDataComplete{
NSLog(@"loadDataComplete called");
}
but my secondViewController is not calling the protocol methad. Why is it so? Any suggestion will be appreciated.