title: Calling delegate method through different classes in Swift
body: <p>I am fetching JSON menu and once the JSON returned, I would like to <strong>run menuReady() to update content of the table</strong> within SomeTableViewController class. But the following code doesn't seems to work. </p>
  
  <p><strong>AIM:</strong> Run <em>menuReady()</em> to update content once JSON returned.</p>
  
  <p><strong>PROBLEM:</strong> <em>menuReady()</em> is never fired.</p>
  
  <p><strong><em>SomeTableViewController.swift</em></strong></p>
  
  <pre><code>class SomeTableViewController: UITableViewController, MenuModelDelegate {
      override func viewDidLoad() {
          menuModel.delegate = self
      }
      func menuReady() {
          // This is NOT fired.
          print("SomeViewController.menuReady()")
      }
  }
  </code></pre>
  
  <p><strong><em>MenuModel.swift</em></strong></p>
  
  <pre><code>protocol MenuModelDelegate : class {
      func menuReady()
  }
  
  class MenuModel: NSObject {
      var delegate:MenuModelDelegate?
      func getMenu(data: JSON) {
          // This is fired.
          print("MenuModel.getMenu()")
          delegate?.menuReady()
      }
  }
  </code></pre>
  
  <p><strong><em>Call from AnotherViewController when button tapped</em></strong></p>
  
  <p><strong><em>AnotherViewController.swift</em></strong></p>
  
  <pre><code>class AnotherViewController : UIViewController {
      func buttonTapped(sender: UIButton!) {
          // This function is fired.
          // jsonData is some json data returned from http request
          let menuModel = MenuModel()
          menuModel.getMenu(data: jsonData)
      }
  }
  </code></pre>