Static NSString * CellIdentifier = @ "Cell"; // reuse cell JKCallbacksTableViewCell * cell = (JKCallbacksTableViewCell *) [tableView failed: CellIdentifier]; if (Cell = nil) {cell = [[[JKCallbacksTableViewCell alloc] initWithStyle: Repeated reuseIdentifier: CellIdentifier] autorelease];} // obtain the NSString * imageFilename = [imageArray objectAtIndex: [indexPath r Ow]; NSString * imagePath = [imageFolder stringByAppendingPathComponent: imageFilename]; // image name [[cell textLabel] setText: imageFilename]; [cell setSelectionStyle: uitableviewcellselectionstyone]; // If we already have an image cached for the cell, use that. otherwise we need to go into the // background and generate it. UIImage * image = [imageCache objectForKey: imageFilename]; if (image) {// image Cache Does not exist. Load the image [[cell imageView] setImage: image];} else {dispatch_queue_t queue = dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul ); // Get the height of the cell to pass to the block. CGFloat cellHeight = [tableView rowHeight]; // Now, we can't cancel a block once it begins, so we'll use associated objects and compare // index paths to see if we shoshould continue once we have a resized im Age. // create an association object/*** @ param cell source object * @ param kIndexPathAssociationKey join key * @ param indexPath join value * @ param OBJC_ASSOCIATION_RETAIN join method */objc_setAssociatedObject (cell, kIndexPathAssociationKey, indexPath, OBJC_ASSOCIATION_RETAIN);/* you can add data to an object without modifying the class definition, which is useful when you do not have the source code of this class, or you cannot modify this object for binary compatibility reasons. An association is based on a key. Therefore, you can add multiple associations to an object. Different keys are used for each association. The associated object can also ensure that the associated object exists, at least within the life cycle of the source object (that is, this object is not likely to be introduced to the garbage collection system) */dispatch_async (queue, ^ {// sub-thread UIImage * image = [UIImage imageWithContentsOfFile: imagePath]; // adjust the image size UIImage * resizedImage = [image resize: Export bounds: CGSizeMake (cellHeight, cellHeight) interpolationQuality: kCGInterpolationHigh]; dispatch_async (Disconnect (), ^ {// main thread (Asynchronous Operation) // retrieves the correlated object NSIndexPath * cellIndexPath = (NSIndexPath *) objc_getAssociatedObject (cell, kIndexPathAssociationKey); if ([indexPath isEqual: cellIndexPath]) {[[cell imageView] setImage: resizedImage];} // cache key [imageCache setObject: resizedImage forKey: imageFilename] ;}) ;}