How to call base class method when any method in subclass is being called?

81 Views Asked by At

I am working on XCUITest. My requirement in Swift is to have a takeScreenshot() method in the BasePage and capture screenshots when any method in SubPage:BasePage is being called without actually having to call takeScreenshot() method.

How can we achieve this in Swift? Something on lines of sniffing during runtime. On calling any of the methods of the subclass takeScreenshot() should be executed.

class BasePage {
   func takeScreenshot(){
    ...
   }
}
class SubPage: BasePage {
   func step1(){

   }
   func step2(){

   }
}
0

There are 0 best solutions below