title: How to download 100 images from server in Objective-C using NSURLSession
body: <p>I am making an app..</p>
  
  <p>I need to download many pictures from a server, but I don't know how to do</p>
  
  <p>previously am doing this by following some articles </p>
  
  <p>currently am facing some issues 
   when scrolling images flicker and change all the time. When scrolling back up fast, all images are wrong. What can I do about that? </p>
  
  <pre><code>- (void)downloadImageWithURL:(NSURL *)url completionBlock:(void (^)(BOOL succeeded, UIImage *image))completionBlock
  {
      NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
      [NSURLConnection sendAsynchronousRequest:request
                                         queue:[NSOperationQueue mainQueue]
                             completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
                                 if ( !error )
                                 {
                                      UIImage *image = [[UIImage alloc] initWithData:data];
                                      completionBlock(YES,image);
                                  } else{
                                      completionBlock(NO,nil);
                                  }
                             }];
  }
  
  
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *cellIdentifier = @"venue";
      UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
  
      if (!cell) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
      }
  
      Venue *venue = ((Venue * )self.venues[indexPath.row]);
      if (venue.userImage) {
          cell.imageView.image = venue.image;
      } else {
          // set default user image while image is being downloaded
          cell.imageView.image = [UIImage imageNamed:@"default.png"];
  
          // download the image asynchronously
          [self downloadImageWithURL:venue.url completionBlock:^(BOOL succeeded, UIImage *image) {
              if (succeeded) {
                  // change the image in the cell
                  cell.imageView.image = image;
  
                  // cache the image for use later (when scrolling up)
                  venue.image = image;
              }
          }];
      }
  }
  </code></pre>
  
  <p>**Any best way suggestions **</p>