title: Image View is Causing Awkward Hang?
body: <p>I've been working on this for a couple days now (off &amp; on) and I'm not <em>exactly</em> sure why this isn't working, so I'm askin you pros at SOF for some insight.</p>
  
  <h1>NewsItem.m</h1>
  
  <p>On my first view controller, I'm reading from a JSON feed which has 10+ items. Each item is represented by a <code>NewsItem</code> view which allows for a title, body copy, and a small image. The <code>UIImageView</code> has an <code>IBOutlet</code> called <strong>imageView</strong>. I'm loading the image for my <strong>imageView</strong> asynchronously. When the image is loaded, I'm dispatching a notification called <strong>IMAGE_LOADED</strong>. This notification is only picked up on the the <strong>NewsItemArticle</strong></p>
  
  <pre><code>dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  //this will start the image loading in bg
  dispatch_async(concurrentQueue, ^{
      NSData *image = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:self.imageURL]];
      //this will set the image when loading is finished
      dispatch_async(dispatch_get_main_queue(), ^{
          [self.imageView setAlpha:0.0];
          self.image = [UIImage imageWithData:image];
          [self.imageView setImage:self.image];
          [UIView animateWithDuration:0.5 animations:^{
              [self.imageView setAlpha:1.0];
          }];
  
          if(self)
          [[NSNotificationCenter defaultCenter] postNotificationName:IMAGE_LOADED object:self];
      });
  });
  </code></pre>
  
  <h1>NewsItemArticle.m</h1>
  
  <p>When a user taps on a <strong>NewsItemView</strong> then I load a new controller which is a scroll view of several <strong>NewsItemArticle</strong> views inside a scrollview. A <strong>NewsItemArticle</strong> will listen for <strong>IMAGE_LOADED</strong> and if it is decided the current notification has an image for this particular article, it will use the same image for it's own reference like so:</p>
  
  <pre><code>- (void)handleImageLoaded:(NSNotification *)note
  {
      if([note.object isEqual:self.cell]) {
          // this next line is hanging the app. not sure why.
          [self.imageView setImage:self.cell.image];
          [self.activityViewIndicator removeFromSuperview];
      }
  }
  </code></pre>
  
  <p>So essentially:</p>
  
  <ul>
  <li>I'm using an asynchronous load on my first image reference</li>
  <li>I'm using notifications to let other parts of the app know and image was loaded</li>
  <li>The app hangs when the existing image is reference to a second <code>UIImageView</code></li>
  </ul>
  
  <p>If I comment out the <em>suspect</em> line, the app never hangs. As it its, my app hangs until all the images are loaded. My thoughts are:</p>
  
  <ol>
  <li>This is a network threading conflict (not likely)</li>
  <li>This is a GPU threading conflict (perhaps during a resize to the container view's size?)</li>
  </ol>
  
  <p>Has anyone seen anything like this before?</p>