title: How can i speed up UIImageView/UIButton in UITableViewCell?
body: <p>I originally tried using core graphics to draw my images into the cells, but that was working slowly, because my images were quite big. Now i'm using UIImageViews in my cells to display 1 image in each cell.</p>
  
  <p>Because i'm caching the images, it scrolls perfectly smoothly after the first time of loading each cell. When it loads for the first time though, there's a little bit of lag.</p>
  
  <p>There's not really much I can show you because this is a fairly generic question, but I guess I can show you how i'm loading my images so far:</p>
  
  <pre><code>- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  {
      self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
      if (self) {
  
          self.isReadyForImage = NO;
  
          NSString *generated = [Entry generateString];
  
          const char *cString = (const char*)[generated UTF8String];
  
          dispatch_queue_t queue = dispatch_queue_create(cString, NULL);
          dispatch_async(queue, ^{
  
              self.thumbnailButton = [[UIButton alloc] init];
              self.thumbnailButton.contentMode = UIViewContentModeCenter;
              self.thumbnailButton.layer.shadowColor = [[UIColor blackColor] CGColor];
              self.thumbnailButton.layer.shadowOffset = CGSizeMake(0, 2);
              self.thumbnailButton.layer.shadowOpacity = 0.2;
              self.thumbnailButton.layer.shadowRadius = 3;
              self.thumbnailButton.userInteractionEnabled = YES;
  
              dispatch_async(dispatch_get_main_queue(), ^{
                  self.isReadyForImage = YES;
  
                  if (self.imageToBecomeThumbnail != nil) {
                  [self setupThumbnail];
                  }
              });
  
          });
  self.selectionStyle = UITableViewCellSelectionStyleNone;
  
      }
      return self;
  }
  -(void)resetShadowPath {
     self.thumbnailButton.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.thumbnailButton.bounds].CGPath;
  }
  
  -(void)setThumbnail:(UIImage *)image {
  
      self.imageToBecomeThumbnail = image;
  
      if (self.isReadyForImage == YES) {
          [self setupThumbnail];
      }
  }
  
  -(void)setupThumbnail {
      [self.thumbnailButton setImage:self.imageToBecomeThumbnail forState:UIControlStateNormal];
  
      self.thumbnailButton.frame = CGRectMake(0, IMAGE_SPACING, self.imageToBecomeThumbnail.size.width, self.imageToBecomeThumbnail.size.height);
      self.thumbnailButton.center = CGPointMake(self.bounds.size.width / 2, self.thumbnailButton.center.y);
      [self resetShadowPath];
      [self.thumbnailButton addTarget:self action:@selector(thumbnailPressed:) forControlEvents:UIControlEventTouchUpInside];
  
      if (self.thumbnailButton.superview == nil) {
          [self addSubview:self.thumbnailButton];
      }
  }
  </code></pre>
  
  <p>Side note: I'm not referring to my dispatch queue's anywhere else. It said each one needed a unique one, so i busted out this random string generator code. Does it need to be unique, or does it not really matter if they're not going to be referred to again?</p>