I'm new in IOS, and can't understand some things about delegates and protocols. In my project I'm using AMSlideMenu for slide menu. I need to update same data in slide menu. For that I need to catch openMenu callback. In instruction for slide menu I found this
If you want to get menu's open/close callbacks, then set MainVC's delegate property, and implement protocol named 'AMSlideMenuProtocols'.
@optional
- (void)leftMenuWillOpen;
- (void)leftMenuDidOpen;
- (void)rightMenuWillOpen;
- (void)rightMenuDidOpen;
I tried to catch callback with this code
//myClass.h
#import "AMSlideMenuLeftTableViewController.h"
#import "AMSlideMenuMainViewController.h"
@interface myClass : AMSlideMenuLeftTableViewController<AMSlideMenuDelegate>
@end
//myClass.m
#import "myClass.h"
@interface myClass ()
@end
@implementation myClass
-(void)leftMenuWillOpen
{
//something
}
@end
but leftMenuWillOpen
never gets invoked. What I did wrong?
Swift 2.0 compatible
This is my case, but I guess is the general situation:
Where LeftMenuViewController is a custom class that inherits from AMSlideMenuLeftTableViewController.
I guess you are not setting the delegate to the slide menu. The object of myClass should be the delegate to AMSlideMenu object.
To complete the answer and for a quick reference, you need to add this to your viewDidLoad :