Sdwebimage EXC_BAD_ACCESS

I am using https://github.com/rs/SDWebImage to upload images to a UITableView. This is how I implemented this (simple) inside cellForRowAtIndexPath

[cell.imageView setImageWithURL:[NSURL URLWithString:[item valueForKey:@"icon"]]placeholderImage:[UIImage imageNamed:@"icon_events_default.png"]]; 

After the images are loaded into the UITableView, I scroll down and then again and get the error: EXC_BAD_ACCESS

 - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { SDWebImageManager *manager = [SDWebImageManager sharedManager]; // Remove in progress downloader from queue [manager cancelForDelegate:self]; UIImage *cachedImage = [manager imageWithURL:url]; if (cachedImage) { //EXC_BAD_ACCESS hapens here self.image = cachedImage; } else { if (placeholder) { self.image = placeholder; } [manager downloadWithURL:url delegate:self]; } } 

Any help really appreciated.

+4
source share
1 answer

Did you run this code through Zombies in Instruments? This should immediately indicate a problem. Just select “Profile” in the “Product” menu, the tools will start, select the “Zombie” tool, then run a test script that causes this problem and you should see a pop-up window with zombies showing how the object is still being used, even if it is no longer valid.

If I were to guess, you are not properly saved by the UITableViewCell, and it is either freed or reused too quickly before the image on the url is loaded.

+1
source

All Articles