title: Reference to instance variables inside a block
body: <p>Suppose I have a class (non-ARC environment):</p>
  
  <pre><code>@interface SomeObject : NSObject {
      UILabel *someLabel;
      dispatch_queue_t queue;
  }
  - (void)doAsyncStuff;
  - (void)doAnimation;
  @end
  
  @implementation SomeObject
  
  - (id)init {
      self = [super init];
      if (self) {
          someLabel = [[UILabel alloc] init];
          someLabel.text = @"Just inited";
          queue = dispatch_queue_create("com.me.myqueue", DISPATCH_QUEUE_SERIAL);
      }
      return self;
  }
  
  - (void)doAsyncStuff {
      dispatch_async(queue, ^{
          ...
          // Do some stuff on the current thread, might take a while
          ...
          dispatch_async(dispatch_get_main_queue(), ^{
              someLabel.text = [text stringByAppendingString:@" in block"];
              [self doAnimation];
          }
      }
  }
  
  - (void)doAnimation {
      ...
      // Does some animation in the UI
      ...
  }
  
  - (void)dealloc {
      if (queue) {
          dispatch_release(queue);
      }
      [someLabel release];
      [super dealloc];
  }
  </code></pre>
  
  <p>If my block gets kicked off and then everything else holding a reference to the instance of this object releases it, am I guaranteed that dealloc won't be called because the nested block refers to an instance variable (and to self) -- that dealloc will happen after the nested block exits? My understanding is that my block has a strong reference to self, so this should be kosher.</p>