SDWebImage UIImageView+WebCache crashing on 64 bit

2019-07-20 20:53发布

问题:

I have this code:

#import <SDWebImage/UIImageView+WebCache.h>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
[cell.thumbnail setImageWithURL:[NSURL URLWithString:thumbnailURL] placeholderImage:[UIImage animatedImageWithImages:loadingArray duration:1] options:indexPath.row == 0 ? SDWebImageRefreshCached : 0];
}

where "loadingArray" is just an array of png images. cellForRowAtIndexPath obviously has a lot more code.

This code works on 32 bit devices and emulator on 32 bit, but it crashes on 64 bit devices and 64 bit emulator.

Here's the crash report from XCode:

-[UIImageView setImageWithURL:placeholderImage:options:]: unrecognized selector sent to instance 0x110942780
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setImageWithURL:placeholderImage:options:]: unrecognized selector sent to instance 0x110942780'

I am using the SDWebImage-3.6 framework re-downloaded today (Apr. 22 2014) Cleaned the project, re-added the app to the emulator...same issue.

Any suggestion to fix this issue would be highly appreciated. Thank you.

回答1:

I have solved this issue by changing the Build settings of SDWebImage to "(armv7,arm64)" . Got a few errors in "NSLog" but those are easy fixes, apart from the fact that you need to change the following:

- (int)getMemoryCount
{
    return [[memCache allKeys] count];
}

in SDImageCache.m to

- (int)getMemoryCount
{
    return (int)[[memCache allKeys] count];
}