title: Using weak reference to check if object is deallocated, in Objective-C
body: <p>I'm using ARC.<br>
  Sometimes I wrote the following code to assert a object should be deallocated:</p>
  
  <pre><code>__weak weakVariableOrProperty = someObject;
  ....
  
  someObject = nil;
  // or someObject = anotherObject;
  ....
  
  if (weakVariableOrProperty) {
      @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Object not deallocated" userInfo:nil];
  }
  </code></pre>
  
  <p>For example, I use this code to check if a view controller is deallocated before creating a new view controller. </p>
  
  <p>I believe that weak variable or weak property is set to nil <strong>immediately</strong> after last strong variable or property was set to nil or another object.<br></p>
  
  <p>And this code is working as I expected until now.<br></p>
  
  <p>Using weak variable or property to check if object is deallocated is a technique commonly used?<br>
  Is it possible that this code will cause problem in the future?</p>