title: AFNetworking + progress view + performance
body: <p>In my app users can download large files (1GB+). I have own progress view to indicate downloading progress. And I'm using <code>AFNetworking</code> like this</p>
  
  <pre><code>[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead){
                  [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
                  double progress = (double)(size + totalBytesRead) / (size + totalBytesExpectedToRead);
                  [[NSNotificationCenter defaultCenter] postNotificationName:ETBDownloadManagerProgressNotification object:component userInfo:@{ ETBDownloadProgressKey : [NSNumber numberWithDouble:progress], ETBDownloadExpectedSizeKey : [NSNumber numberWithDouble:(size + totalBytesExpectedToRead)*1.0/1024.0/1024.0] }];
          }];
  </code></pre>
  
  <p>I have a problem with performance while downloading files. At the same time it's possible to download only one file. Time Profiler shows that I update UI and call <code>drawRect:</code> very often. So here's my progress view setProgress:</p>
  
  <pre><code>- (void)setProgress:(double)progress
  {
      _progress = progress;
      if (_progress &gt; 1)
          _progress = 1;
      self.textLabel.text = [NSString stringWithFormat:@"%.f%%", 100*self.progress];
      [self setNeedsDisplay];
  }
  </code></pre>
  
  <p>And progress view drawRect:</p>
  
  <pre><code>- (void)drawRect:(CGRect)rect
  {
      UIBezierPath* bezierPath = [UIBezierPath bezierPath];
      [bezierPath addArcWithCenter:CGPointMake(rect.size.width/2, rect.size.height/2)
                            radius:rect.size.width/2 - kLineWidth/2 - kPadding
                        startAngle:0
                          endAngle:2*M_PI
                         clockwise:YES];
  
      bezierPath.lineWidth = kLineWidth;
      [[UIColor colorWithRed:1 green:1 blue:1 alpha:.3] setStroke];
      [bezierPath stroke];
  
      bezierPath = [UIBezierPath bezierPath];
      [bezierPath addArcWithCenter:CGPointMake(rect.size.width/2, rect.size.height/2)
                            radius:(rect.size.width/2 - kLineWidth - kPadding)/2
                        startAngle:startAngle
                          endAngle:(endAngle - startAngle) * self.progress + startAngle
                         clockwise:YES];
  
      bezierPath.lineWidth = rect.size.width/2 - kLineWidth - kPadding;
      [[UIColor colorWithRed:1 green:1 blue:1 alpha:.3] setStroke];
      [bezierPath stroke];
  }
  </code></pre>
  
  <p>The question is how to avoid lagging? The only way I found is to decrease number of <code>postNotification</code> for updating UI. But how? I tried to use condition like <code>if (i++%3 == 0)</code> inside <code>setDownloadProgressBlock</code>, but it's ugly :)
  I also tried to replace <code>self.textLabel.text = ...</code> to <code>drawRect:</code>, but it made no sense.
  Maybe it's possible to set the size of downloading pack?</p>