title: Capture system volume changes in Swift
body: <p>Reading the following advices about getting and setting system volume in osX, I use the ISSoundAdditions which works great:</p>
  
  <p><a href="https://stackoverflow.com/questions/6278589/change-volume-on-mac-programmatically/25220019?s=1|0.2860#25220019">Change Volume on Mac programmatically</a></p>
  
  <p>and</p>
  
  <p><a href="https://stackoverflow.com/questions/36953948/set-os-x-volume-in-os-x-10-11-using-swift-without-using-the-deprecated-audiohard/36954944?s=2|0.2564#36954944">Set OS X volume in OS X 10.11 using Swift without using the deprecated AudioHardwareServiceSetPropertyData API</a></p>
  
  <p>I can directly manage the system sound volume with a NSSlider (with bindings).
  My question is: how can I capture the volume changed as an event (for exemple when the volume up and down keys in the keyboard ? In theses cases, my slider doesn't react.
  I experimented :</p>
  
  <pre><code>self.addObserver(self, forKeyPath: "volume.systemVolume", options: NSKeyValueObservingOptions.New, context: &amp;volumeContext)
  </code></pre>
  
  <p>But then I get an exception: </p>
  
  <blockquote>
    <p>Cannot update for observer XX for the key path "volume.systemVolume",
    most likely because the value for the key "volume" has changed without
    an appropriate KVO notification being sent. Check the KVO-compliance
    of the class.</p>
  </blockquote>
  
  <p>BTW, <code>systemVolume</code> property is a class property, if it matters?</p>
  
  <p>Many thanks for your help</p>
  
  <p>Joshua</p>