Search code examples
iphoneiosobjective-ccomposite

Can I invoke the composite's super's method in Objective-C


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?


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