ios - Delegate Method is not getting called -


i trying pass selected cell text categoryviewcontroller describeviewcontroller. not call method in describeviewcontroller method.

categoryviewcontroller.h

#import <uikit/uikit.h> @protocol categoryviewcontrollerdelegate <nsobject>  - (void)didselectrow:(nsstring *)celldatastring;  @end  @interface categoryviewcontroller : uiviewcontroller<uitableviewdelegate, uitableviewdatasource> @property (weak, nonatomic) id<categoryviewcontrollerdelegate> delegate;  @end 

categoryviewcontroller.m

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell = [categorytableview cellforrowatindexpath:indexpath];     nsstring *celltext = cell.textlabel.text;     [self.delegate didselectrow:celltext];     [[self navigationcontroller] popviewcontrolleranimated:yes]; } 

describeviewcontroller.h

#import <uikit/uikit.h> #import "categoryviewcontroller.h"  @interface describeviewcontroller : productawarebaseviewcontroller<uitextfielddelegate, categoryviewcontrollerdelegate> 

the following didselectrow method not getting called. not able find out root of problem.

describeviewcontroller.m

- (void)viewdidload {     [super viewdidload];     // additional setup after loading view.             categoryviewcontroller *popovertableviewcontroller = [[categoryviewcontroller alloc] init];     popovertableviewcontroller.delegate = self;  }  - (void)didselectrow:(nsstring *)celldatastring {     self.celldatastring = celldatastring; } 

productawarebaseviewcontroller.h

@import uikit;  @class product;  @interface productawarebaseviewcontroller : uiviewcontroller @property (nonatomic, strong) product *product; @end 

productawarebaseviewcontroller.m

#import "productawarebaseviewcontroller.h" #import "product.h"  @interface productawarebaseviewcontroller ()  @end  @implementation productawarebaseviewcontroller  - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {     if ([segue.destinationviewcontroller iskindofclass:[productawarebaseviewcontroller class]]) {         productawarebaseviewcontroller *vc = (productawarebaseviewcontroller *)segue.destinationviewcontroller;         vc.product = self.product;     } } @end 

try setting delegate object in didselectrow. , call delegate method after that. because delegate weak, may released memory.

categoryviewcontroller *popovertableviewcontroller = [[categoryviewcontroller alloc] init];     popovertableviewcontroller.delegate = self;  uitableviewcell *cell = [categorytableview cellforrowatindexpath:indexpath];     nsstring *celltext = cell.textlabel.text;     [self.delegate didselectrow:celltext];     [[self navigationcontroller] popviewcontrolleranimated:yes]; 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -