title: Trying to fade in images loaded from URL asynchronously in XCode
body: <p>I want to load images from a URL and then assign them as background images for different UIButtons. I need to do this when a view appears.</p>
  
  <p>My problem is that when I try to make the images fade in when they are loaded, the animation does not start until all of the images have loaded. I think this is because the animation code is read but that before it has time to be executed, the program starts loading a new image.</p>
  
  <p>How can I make images fade in one after the other?</p>
  
  <p>The following code is used to get the image (calling downloadImageByPrice atURL) and then does the animation.</p>
  
  <pre><code>-(void) obtainImage:(int)i atURL:(NSString *)URLString{
  
      UIImage *image = [self downloadImageByPrice:i atURL:URLString];
  
      // Make images fade in when they have been found
      [[_buttonArray objectAtIndex:i] setAlpha:0.0];
  
      [[_buttonArray objectAtIndex:i] setImage:image forState:UIControlStateNormal];
  
      [UIView beginAnimations:@"fadeIn" context:nil];
      [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
      [UIView setAnimationDuration:0.8];
  
      [[_buttonArray objectAtIndex:i] setAlpha:1.0];
      [UIView commitAnimations];
  
  
  }
  </code></pre>
  
  <p>This method is used to load all the images one after the other. I want my loop to wait until each image has appeared before starting to load the next one.</p>
  
  <pre><code>-(void) loadAllImagesAtURL:(NSString *)URLString{
      for(int i =0; i&lt;[_buttonArray count];i++){
          [self obtainImage:i atURL:URLString];
      }    
  }
  </code></pre>
  
  <p>I have tried using selectors, or the completion^ method with no luck, but my understanding of those concepts is still pretty low.</p>
  
  <p>Thank you</p>