0

I'm using SDWebImage framework to download profile images in my iPhone game.

[cell.playerImage setImageWithURL:url placeholderImage: DefaultImage]; 

This works great, but I'm worried about the server performance. Each time the tableView is reloaded, all the cell will call the the code above to try to get the image. And the tableView is realoaded quite often.

Since most player don't have a profile image, the DefaultImage will be set, but I still want to check from time to time if the opponent player has uploaded a profileImage, so I can get it, but not in each and every tableView reload.

How would you go about doing this?

Thanks in advance

BlackMouse
  • 4,442
  • 6
  • 38
  • 65

1 Answers1

1

Save player image in document Directory first time when it requests for image from server with names playername.png or playerID.png (varies what unique u want for that).

In SDWebImage setImageWithURL's method add this logic:

if([[NSFileManager defaultManager] fileExistsAtPath:@"Your Player Image Path"])  
{
    // set image from local Path
}
else
{
   //request from server
   // save image in document Directory and then set that image
}
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132