title: Safe Key Value Observing of keypaths
body: <p>I am trying to implement a safe key value observing on keypaths. Let's suppose that I have a data model object named <code>person</code> that have a <code>workplace</code> property. The <code>workplace</code> in turn have a <code>address</code> property  that I wish to observe so I set up key value observing with the following call: </p>
  
  <pre><code>[person addObserver:theObserver 
           forKeyPath:@"workplace.address" 
              options:NSKeyValueObservingOptionNew 
              context:NULL];
  </code></pre>
  
  <p>This works fine until the person does not change workplace. As soon as this happens:</p>
  
  <pre><code>person.workplace = newWorkplace;
  </code></pre>
  
  <p>the KVC system crashes the application correctly saying that "oldAddress was deallocated while key value observers were still registered with it". (being oldAddress the address of the previous workplace).</p>
  
  <p>Unfortunately I can not tweak the implementation of the class of 'person' object to notify the observer that workplace is going to go away. Are there any pattern to avoid this kind of crash?  Maybe one can get some other notifications? How is the keypath being traversed in the case of KVC and do you have access to this chain?</p>