gpt4 book ai didi

ios - SDImageCache - 4.0 迁移后无法识别的选择器错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:09:19 26 4
gpt4 key购买 nike

我最近将一个项目升级到 SDWebImage 4.0,我只用它来缓存图像并稍后检索它们。如果它在 3.x 版本上完美运行。迁移后我现在收到以下错误...

-[SDImageCache storeImage:forKey:toDisk:completion:]: unrecognized selector sent to instance 0x174097cf0

这看起来应该是一个简单的错误来解决,但在多次尝试后,我无法修复它。

这是我以前的 3.x API 代码...

@property (strong, nonatomic) SDImageCache *imageCache;
- (SDImageCache *)imageCache {

if (!_imageCache) {
_imageCache = [[SDImageCache alloc] initWithNamespace:NAME_SPACE_IMAGE_CACHE];

}

return _imageCache;
}


[self.imageCache storeImage:[UIImage imageWithContentsOfFile:imageData.imageURL.path] forKey:imageData.imageURL.absoluteString toDisk:YES];

这是我为 4.0 API 更新的代码,这是抛出错误的代码行...

[self.imageCache storeImage:[UIImage imageWithContentsOfFile:imageData.imageURL.path] forKey:imageData.imageURL.absoluteString toDisk:YES completion:^{
NSLog(@"INFO: Image cached successfully!");
}];

有人可以帮助澄清问题是什么吗?

提前致谢!

最佳答案

我这样尝试并且有效,您必须 shift + cmd + k 并重新构建,必须解决这里指出的问题 https://github.com/rs/SDWebImage/issues/1602

#import "ViewController.h"

@interface ViewController ()
@property SDImageCache * imageCache;
@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

self.imageCache = [SDWebImageManager sharedManager].imageCache;
// Do any additional setup after loading the view, typically from a nib.
[_imageCache storeImage:[UIImage imageNamed:@"test"] forKey:@"testKey" toDisk:YES completion:^{
NSLog(@"INFO: Image cached successfully!");
}];

}


- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


@end

CONSOLE OUTPUT

2017-07-11 00:55:12.146 SDWebImageSOQuestion[17275:339149] INFO: Imagecached successfully!

希望对你有帮助

关于ios - SDImageCache - 4.0 迁移后无法识别的选择器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45020422/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com