iOS Delegate not called -
for project need able send status "secondtableviewcontroller" "firsttableviewcontroller". followed tutorials on delegates don't seem work. when want call method in firsttableviewcontroller secondtableviewcontroller check see if "delegate" property empty, , every time is..
this code:
secondtableviewcontroller.h
@protocol sendstatusdelegate <nsobject> @required -(void)didstatuschanged; @end // eof delegate protocol @interface secondtableviewcontroller : uitableviewcontroller @property (nonatomic, assign) id<sendstatusdelegate> delegate; @end
secondtableviewcontroller.m
// status changed on row click - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { if (self.delegate) { // never called because delegate looks remain empty [self.delegate didstatuschanged]; } }
firsttableviewcontroller.h
@interface firsttableviewcontroller : uitableviewcontroller <sendstatusdelegate> @end
firsttableviewcontroller.m
the thing goes on here implementing -(void)didstatuschanged method.
first need set delegate
self in firsttableviewcontroller
when init secondtableviewcontroller
. on didselectrowatindexpath:
calling secondtableviewcontroller
in case,
firsttableviewcontroller.m // status changed on row click - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { secondtableviewcontroller *secondtablevc = [secondtableviewcontroller alloc] init]; secondtablevc.delegate = self; }
Comments
Post a Comment