0

I am Trying to integrate SdWebImage With Youtube Api for the purpose of Fetching thumbnail image to cache them so as get rid of scrolling problem in UITableView.Problem is Youtube API Provide a URL that is for Thumbnail NSDATA which can be converted back to UIImage object but SDWebImage is Takes URL to an image to manage images in best efficient method.

Youtube Api Method:

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[thumbnails objectAtIndex:0] URLString]]];
UIImage * image = [UIImage imageWithData:data];

SDWebImage Method

[cell.imageView setImageWithURL:[NSURL URLWithString:[_objects objectAtIndex:indexPath.row]]
               placeholderImage:[UIImage imageNamed:@"placeholder"]];

Please Tell How We Solve this Problem.

jonkroll
  • 15,682
  • 4
  • 50
  • 43

1 Answers1

0

I think you are overthinking this problem. You should be able to just do this:

NSURL *thumbnailURL = [NSURL URLWithString:[[thumbnails objectAtIndex:indexPath.row] URLString]]];

[cell.imageView setImageWithURL:thumbnailURL
               placeholderImage:[UIImage imageNamed:@"placeholder"]];
jonkroll
  • 15,682
  • 4
  • 50
  • 43
  • Thank you very much sir It worked..... only we had to make a slight change to it.. NSURL *thumbnailURL = [NSURL URLWithString:[[thumbnails objectAtIndex:0] URLString]]]; [cell.imageView setImageWithURL:thumbnailURL placeholderImage:[UIImage imageNamed:@"placeholder"]]; – Sohaib Hussain Aug 14 '12 at 02:49