So I have an app that looks similar to the Youtube app. A Table view and in each cell an Image with text describing the record.
However, after launching the app I've received complaints about the performance when scrolling through the list in the Table View. I hadn't seem this during testing or development so I didn't know it existed, but that's my fault for not properly testing as much as I could.
Any way, to populate the images I am pulling them from the internet using the follow code with in the cellForRowAtIndexPath method
I am recycling the TableViewCell with dequeueReusableCellWithIdentifier so my understanding is that the code will run every time the cell is coming back on screen. However now that I think about it here is my question. Will the program try to dl the images every time the cell is displayed again? Or are they cached some where? Even though the images are small I think if they have to be downloaded again every time the user scrolls through the records that may be the cause of my performance issues.
If this is the case where they images are being redownloaded every time instead of being cached, what would be an efficient way to go about caching that images?
However, after launching the app I've received complaints about the performance when scrolling through the list in the Table View. I hadn't seem this during testing or development so I didn't know it existed, but that's my fault for not properly testing as much as I could.
Any way, to populate the images I am pulling them from the internet using the follow code with in the cellForRowAtIndexPath method
Code:
UIImage *uiThumbImage;
if(itemobj.image != nil)
{
NSURL *imageUrl = [NSURL URLWithString: itemobj.image];
NSData *imageData = [NSData dataWithContentsOfURL: imageUrl];
uiThumbImage = [[UIImage alloc] initWithData:imageData];
}
else
{
uiThumbImage = [UIImage imageName: @"DefaultThumb.png"];
}
[[cell uiImage] setImage:uiThumbImage];
I am recycling the TableViewCell with dequeueReusableCellWithIdentifier so my understanding is that the code will run every time the cell is coming back on screen. However now that I think about it here is my question. Will the program try to dl the images every time the cell is displayed again? Or are they cached some where? Even though the images are small I think if they have to be downloaded again every time the user scrolls through the records that may be the cause of my performance issues.
If this is the case where they images are being redownloaded every time instead of being cached, what would be an efficient way to go about caching that images?