title: Overriding bind method (Swift) - Err: Value of type 'Any' has no member 'addObserver'
body: <p>I'm pretty new to Swift and "Apple" programming so excuse me if my question is silly.</p>
  
  <p>I'm trying to sub-class NSPopupButton in order to add an option for binding the menu items' image property.</p>
  
  <p>I want to override the "bind" function:</p>
  
  <pre><code>override func bind(_ binding: NSBindingName, to observable: Any, withKeyPath keyPath: String, options: [NSBindingOption : Any]? = nil) 
  </code></pre>
  
  <p>And to observe the "observable" parameter so this is the code I have written till now:</p>
  
  <pre><code>class WDPopupButton: NSPopUpButton
  {
      static let ImageBindingContext: UnsafeMutableRawPointer? = UnsafeMutableRawPointer(mutating: "imageContext")
  
      override func bind(_ binding: NSBindingName, to observable: Any, withKeyPath keyPath: String, options: [NSBindingOption : Any]? = nil)
      {
          if(binding == NSBindingName.image)
          {
              guard let observableObject = observable as AnyObject? else
              {
                  return
              }
  
              observable.addObserver(self, forKeyPath: keyPath, options: nil, context: WDPopupButton.ImageBindingContext)
  
              ...
          }
      }
  }
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <pre><code>Value of type 'Any' has no member 'addObserver' 
  </code></pre>
  
  <p>My question is, what do I need to do in order to call addObserver on the observable parameter? </p>
  
  <p>As you can see, I did tried to cast observable to AnyObject type but then I received another error which I couldn't find a solution for.</p>
  
  <p>I changed the addObserver line to:</p>
  
  <pre><code>observableObject.addObserver(self, forKeyPath: keyPath, options: nil, context: WDPopupButton.ImageBindingContext)
  </code></pre>
  
  <p>And got:</p>
  
  <pre><code>Type of expression is ambiguous without more context
  </code></pre>
  
  <p>If casting observable to AnyObject is the solution, than what is this error means and what am i doing wrong?</p>
  
  <p>Thanks</p>