Calling.h //First Class
@protocol myDelegate
@optional
- (void) doIt;
@end
@interface Calling :
id [
}
@property(nonatomic, retain) id
@end
#import " Calling.h"
#import " Called.h "
@implementation Calling
@synthesize delegate;
- (void)viewDidLoad {
[super viewDidLoad];
[delegate hideUnhideMenu];
}
@end
Called.h // Class B
@interface Called : UIViewController
}
@end
Called.m
#import " Called.h"
@implementation Called
- (void)viewDidLoad {
[super viewDidLoad];
Calling* obj = [[Calling alloc] init];
obj.delegate = self;
}
- (void)hideUnhideMenu {
//Do your updation here.
}
@end
NOTE: please replace "[" type of brackets with "<".
for more details about this post click here
property attributes for delegate should be assign. By using retain you are creating retain cycle that will cause memory leak.
ReplyDelete