How to call delegate methods from other class in Swift?

What is the word or phrase you'd use to describe an inheritance relationship where subclasses are expected to call base class methods they override?

  • Example - a test class hierarchy where Subclass::Setup() is expected to call Base::Setup()

  • Answer:

    There is no name for it because this is an error prone pattern that should be avoided. A more correct implementation would be : Abstract Base class : public: virtual void test(){ // common setup this->abstractTest(); } protected: virtual abstract void abstractTest(); The subclass must implement the abstractTest method and the class is tested by calling the test method.

Koen Samyn at Quora Visit the source

Was this solution helpful to you?

Other answers

I would just call it something like "calling the superclass implementation"

Xuan Luo

An example is how the assignment operator of a derived class is implemented: Derived& Derived::operator=(const Derived& rhs) { // check for self-assignment. ... Base::operator=(rhs); // call this->Base::operator= ... } See also http://www.parashift.com/c++-faq-lite/assignment-operators.html#faq-12.4 .

William Wong

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.