Question

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?

Était-ce utile?

La solution

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!)

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top