Pergunta

Say inherited from a class, I can invoke [self someMethod] if someMethod is rewritten; I can also invoke [super someMethod].

What if I use composition instead. Say I have porperty

@propery (nonatomic, strong) XXXController xxController;

Use [self.xxController someMethod] to invoke someMethod, but how to invoke xxController's super version someMethod?

Foi útil?

Solução

No, you can't do this*. Using composition does not allow you to break encapsulation.

*(It is actually possible to do this using runtime functions but you really, really, really shouldn't do that!)

Outras dicas

You can't do that. And you don't want to. Composition styles or not, an object should implement it's own methods, and call it's own super if necessary.

Instead, you should subclass XXXController to work how you want, calling super as necessary in that subclass.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top