Following is my code, there is no error but selector is not responding.
Code in ExampleTableviewSubProductDetail.h
@protocol EnterAmountDelegate <NSObject>
-(void)titlechange:(NSInteger)amount;
@end
@class ASIFormDataRequest;
@interface ExampleTableviewSubProductDetail : UIViewController<UIScrollViewDelegate>
{
}
@property (nonatomic, strong) id <EnterAmountDelegate>delegate;
Code in ExampleTableviewSubProductDetail.m
@implementation ExampleTableviewSubProductDetail
@synthesize delegate;
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if([delegate respondsToSelector:@selector(titlechange:)])
{
//send the delegate function with the amount entered by the user
[delegate titlechange:20];
}
code in HostProductdetailViewController.h
#import "ViewPagerController.h"
#import "ExampleTableviewSubProductDetail.h"
@interface HostProductdetailViewController : ViewPagerController <ViewPagerDataSource, ViewPagerDelegate, EnterAmountDelegate>
{
}
code in HostProductdetailViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
self.dataSource = self;
self.delegate = self;
}
-(void)titlechange:(NSInteger)amount
{
NSLog(@"sdfsf");
}
In the viewwillapper following Line always return false
if([delegate respondsToSelector:@selector(titlechange:)])
Please let me know if i am missing anything.
Thanks
When pushing from HostProductdetailViewController to ExampleTableviewSubProductDetail you need to set the exampleTableviewSubProductDetail.delegate = self