title: How to solve slow scrolling in UITableView
body: <p>I'm testing for the first time on a real device, and after fixing some obvious performance problems, I'm stuck on how do smooth scrolling.</p>
  
  <p>This is what I do:</p>
  
  <ul>
  <li>The data is in sqlite</li>
  <li>I have a small array with the header</li>
  <li>I have in each header array the list of Id's from the Db </li>
  </ul>
  
  <p>e.g.</p>
  
  <p>Header A
     Ids= 1,2;
  Header B
     Ids= 3,4</p>
  
  <ul>
  <li>I lazy load the cell &amp; the object to get the data</li>
  <li>Barely 10 items are loaded at a time</li>
  <li>Loading is fast, only scrolling is a issue</li>
  </ul>
  
  <p>This is the code on the loading of the cell:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      static NSString *CellIdentifier = @"ProductCell";
  
      ProductCell *cell = (ProductCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
      if (cell == nil) {
          NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ProductCell" owner:self options:nil];
  
          cell = [nib objectAtIndex:0];
      }
  
      // Set up the cell...
      Product *p = [self locateRecord:indexPath]; 
  
      cell.nameLabel.text = [p.name capitalizedString];
      cell.codeLabel.text = p.ref;
  
      if ([self.selectedProducts objectForKey:[NSNumber numberWithInt:p.Id]]) {
          OrderDetail *d = [self findDetail:p];
  
          cell.qty.text = [NSString stringWithFormat:@"%ld",[d.qty integerValue]];
      }
  
      return cell;
  }
  
  - (id) locateRecord:(NSIndexPath *)indexPath {
      NSNumber *theId;
      NSUInteger pos = [indexPath row];
  
      id o;
  
      if (self.results) { 
          theId = [self.results objectAtIndex:pos];
      } else {
          NSString *key = [[self.index objectAtIndex:[indexPath section]] objectAtIndex:0];
          NSArray *data = [self.cache objectForKey:key];
  
          theId =  [data objectAtIndex:pos];
      }   
  
      Db *db= [Db currentDb];
  
      o = [db loadById:[self returnItemClass] theId:[theId intValue]];
  
      return o;
  }
  </code></pre>