title: Swift Observer (KVO): Checking for Existence
body: <p>I have a box that the user is able to pan around.  For that, I add an observer to check if it's center has changed:</p>
  
  <pre><code>self.boxView!.addObserver(self, forKeyPath: "center", options: .old, context: &amp;BoxCenterContext)
  </code></pre>
  
  <p>This gets added after an animation that presents the box.</p>
  
  <p>When the box dismisses, I remove it as this:</p>
  
  <pre><code>self.boxView!.removeObserver(self, forKeyPath: "center", context: &amp;BoxCenterContext)
  </code></pre>
  
  <h2>Issue</h2>
  
  <p>There is a possibility of the user being able to dismiss the box before box presentation has been completed, ie. before the KVO is added.  </p>
  
  <p>When that happens, the app crashes trying to remove a KVO that does not exist.</p>
  
  <h2>Question</h2>
  
  <p>Is there a way to check for existence of KVO (before trying to remove)?</p>