title: Swift - Call subclass method on change in variable of super class
body: <p>I have a superclass A and subclass B. Both are ViewControllers. The code is as follows :</p>
  
  <pre><code>class A {
      var a : Bool = false
  }
  
  class B : A {
      var b : Int = 10
      func changeB() {
          b = 20
      }
  }
  </code></pre>
  
  <p>So, theres a variable a in class A. Whenever it changes, it should change the variable b of class B i.e. it should call a method changeB() which will update b.</p>
  
  <p>One way to achieve this is use events to call the method <strong>changeB()</strong> which will update <strong>b</strong>.</p>
  
  <p>Is there any other way to achieve the same thing?</p>
  
  <p>This is just a template for others to understand. The actual problem is - Class A consist of map view and list view and it handles the switching between 2 views. Class B inherits A and has button on top of the view which should be shown only for list view and not for map view.</p>
  
  <p>So, I want to change my <strong>button.isVisible</strong> property which is in <strong>class B</strong>, when the view switches between list view and map view which is handled in <strong>class A</strong>.</p>