objective c - delegate method not getting called -
i have looked @ other questions same problem cannot seem heard around it. pretty sure have done correctly not first time using delegates.
//pdfview.h @class pdfview; @protocol pdfviewdelegate <nsobject> -(void)trialwithpoints:(pdfview*)pdfview; @end @interface pdfview : uiview @property (nonatomic, weak) id <pdfviewdelegate> delegate; in implementation file trying call delegate method touchesmoved delegate of view
//pdfview.m - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event { [self.delegate trialwithpoints:self]; } the class delegate method implemented
//points.h #import "pdfview.h" @interface points : nsobject <pdfviewdelegate> //points.m //this delegate set - (id)init { if ((self = [super init])) { pdfview = [[pdfview alloc]init]; pdfview.delegate = self; } return self; } -(void)trialwithpoints:(pdfview *)pdf { nslog(@"the delegate method called pass points client"); } so how have written delegate , somehow delegate nil , delegate method never called.
at moment not doing delegate, want see working.
any advices on highly appreciated.
i think because did not hold reference instance of delegate, , got released because declared weak. might doing this:
pdfview.delegate = [[points alloc] init]; which should fix like:
_points = [[points alloc] init]; pdfview.delegate = _points; where _points instance variable.
Comments
Post a Comment