title: Observing a value of a static var in a class?
body: <p>I have a class with a <code>static var</code> where the current online connection status is stored. I want to observe the value of <code>ConnectionManager.online</code> through other classes. I wanted to do this with <em>KVO</em>, but declaring a <code>static</code> variable as <code>dynamic</code> causes an error:</p>
  
  <pre><code>class ConnectionManager: NSObject {
      dynamic static var online = false
      // adding 'dynamic' declaration causes error:
      // "A declaration cannot be both 'final' and 'dynamic'
  }
  </code></pre>
  
  <p>What is a most elegant way of doing this?</p>
  
  <p><strong>Update</strong>. This my code for the KVO part:</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
      ConnectionManager.addObserver(
          self,
          forKeyPath: "online",
          options: NSKeyValueObservingOptions(),
          context: nil
      )
  }
  
  override func observeValueForKeyPath(keyPath: String?, 
                                       ofObject object: AnyObject?, 
                                       change: [String : AnyObject]?, 
                                       context: UnsafeMutablePointer&lt;Void&gt;) {
      if keyPath == "online" {
          print("online status changed to: \(ConnectionManager.online)")
          // doesn't get printed on value changes
      }
  }
  </code></pre>