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?

Was it helpful?

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top