title: CollectionView NSURL Session Speed and Reloading
body: <p>I'm fairly new to iOS and developing weather App in when I download hourly forecast along with icon of conditions.  I have been able to implement UICollection with NSURL Connection.  However, I'm having issues regarding speed/performance issues regarding NSURL Session.  Here are the two issues:</p>
  
  <p>1) the speed of downloading and presenting the downloaded icons is very slow (and there are extremely small images).  This download process can take anywhere from 5-10 seconds. </p>
  
  <p>2)  when I put a button to reset the collection, all data is reset, however the existing images remain until the new images are downloaded.  Again this can take anywhere from 5-10 seconds. </p>
  
  <p>Here is my code: </p>
  
  <pre><code> - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  return self.hours.count;
   }
  
  
   - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  static NSString *identifier = @"ConditionsCell";
  
  ConditionsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
  
  cell.conditionsTime.text = [self.hours objectAtIndex:indexPath.row];
  cell.conditionsTemp.text = [NSString stringWithFormat:@"%@°", [self.hoursTemp objectAtIndex:indexPath.row]];
  
  NSURLSession *session = [NSURLSession sharedSession];
  NSURLSessionDataTask *dataTask = [session dataTaskWithURL:[NSURL URLWithString:[self.hoursIcons objectAtIndex:indexPath.row]] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  
      UIImage * serverImage = [UIImage imageWithData: data];
      cell.conditionsImage.image = serverImage;
  
  }];
  
  [dataTask resume];
  
  return cell;
  </code></pre>
  
  <p>}</p>
  
  <p>And here is the IBAction for the button and to reload the CollectionView:</p>
  
  <pre><code> - (IBAction)selectDay:(UISegmentedControl *)sender {
  if (sender.selectedSegmentIndex == 0)
  {
      self.todayOrTomorrow = @"today";
  }
  else if (sender.selectedSegmentIndex == 1)
  {
      self.todayOrTomorrow = @"tomorrow";
  }
  
  self.hours = [self hours];
  self.hoursIcons = [self hoursIcons];
  self.hoursTemp = [self hoursTemp];
  
  [_collectionViewHours reloadData];
   }
  </code></pre>