title: GCD implementation on a UITableView
body: <p>I am doing some heavy calculations when I am creating cells. I am trying to figure out the best way to keep the UITableView fluid, but at the same type do the calculations on the background (keep the UI thread without too much processing). </p>
  
  <p>For testing purposes only, I am using this as my heavy calculation method:</p>
  
  <pre><code>+(NSString*)bigCalculation
  {
      int finalValue=0;
      int j=0;
      int i=0;
  
      for (i=0; i&lt;1000; i++) {
          for (j=0; j&lt;10000000; j++) {
              j++;
          }
          finalValue+=j/100*i;
      }
  
      return [NSString stringWithFormat:@"%d",finalValue];
  }
  </code></pre>
  
  <p>Inside the cellForRowAtIndexPath, I am only doing the following:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      NSString *identifier=@"identifier";
  
      UITableViewCell *cell=nil;
      cell=[aTableView dequeueReusableCellWithIdentifier:identifier];
      if(!cell)
      {
          cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
      }
  
      NSString *text=[dataSource objectForKey:[[dataSource allKeys] objectAtIndex:indexPath.row]];
  
  
      dispatch_queue_t a_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
  ;
      dispatch_async(a_queue, ^{
  
          NSString *subtitle=[CalculationEngine bigCalculation];
          dispatch_async(dispatch_get_main_queue(), ^{
              [[cell detailTextLabel] setText:subtitle];
              dispatch_release(a_queue); 
          });
      });
  
  
      [[cell textLabel] setText:text];
      return cell;
  }
  </code></pre>
  
  <p>At the moment I have the UITableView fluid, while in the background everything is working ok. So my questions are:</p>
  
  <p><strong>1)</strong> Is this the best way to achieve what I want, could KVO be the answer as well?</p>
  
  <p><strong>2)</strong> Before doing this:</p>
  
  <pre><code>dispatch_queue_t a_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
  </code></pre>
  
  <p>I was doing:</p>
  
  <pre><code>dispatch_queue_create("com.mydomain.app.newimagesinbackground", DISPATCH_QUEUE_SERIAL)
  </code></pre>
  
  <p>And the performance was very poor. Could you explain me why?</p>