ios - Subclass as delegate of superclass -


i have class imageviewcontroller. has delegate:

@protocol imageviewcontrollerdelegate @optional - (void)singletapgesturerecognizer:(uitapgesturerecognizer *)gesture; - (void)imagedidloaded; 

i have class attachmentviewcontroller subclass of imageviewcontroller. in class want event image property in changed. here code of change:

- (void)setimage:(uiimage *)image { // * assign image animation [uiview transitionwithview:self.imageview                   duration:k_duration_imageappearence                    options:uiviewanimationoptiontransitioncrossdissolve                 animations: ^{                     self.imageview.alpha = 1;                 } completion:^(bool finished) {                      if ([self respondstoselector:@selector(imagedidloaded)]) {                         [self.delegate imagedidloaded];                     }                 }]; 

but can not use

if ([self.delegate respondstoselector:@selector(imagedidloaded)])  

then have error:

 no known instance method selector 'respondstoselector:' 

why? , how here need use capabilities? implementation ok? or how can notification?

i think here ok create clear methods in superclass , override in subclass if needs implement is. best way?

you should declare protocol @protocol imageviewcontrollerdelegate <nsobject>

this says object conforms protocol conform nsobject protocol respondstoselector: declared in.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -