菜鸟教程小白 发表于 2022-12-11 18:14:12

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


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

<pre><code>-: unrecognized selector sent to instance 0x174097cf0
</code></pre>

<p>这似乎应该是一个简单的错误来解决,但经过多次尝试,我无法修复它。 </p>

<p>这是我以前的 3.x API 代码...</p>

<pre><code>@property (strong, nonatomic) SDImageCache *imageCache;
- (SDImageCache *)imageCache {

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

    }

    return _imageCache;
}


    forKey:imageData.imageURL.absoluteString toDisk:YES];
</code></pre>

<p>这是我为 4.0 API 更新的代码,这是引发错误的代码行...</p>

<pre><code> forKey:imageData.imageURL.absoluteString toDisk:YES completion:^{
                                    NSLog(@&#34;INFO: Image cached successfully!&#34;);
                              }];
</code></pre>

<p>有人可以帮助澄清问题所在吗? </p>

<p>提前致谢!</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我尝试这样并且它有效,您必须 shift + cmd + k 并重新构建,必须解决此处指出的问题 <a href="https://github.com/rs/SDWebImage/issues/1602" rel="noreferrer noopener nofollow">https://github.com/rs/SDWebImage/issues/1602</a> </p>
<pre><code>#import &#34;ViewController.h&#34;

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

@implementation ViewController

- (void)viewDidLoad {
    ;
   
    self.imageCache = .imageCache;
    // Do any additional setup after loading the view, typically from a nib.
    forKey:@&#34;testKey&#34; toDisk:YES completion:^{
      NSLog(@&#34;INFO: Image cached successfully!&#34;);
    }];
   
}


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


@end
</code></pre>
<blockquote>
<p>CONSOLE OUTPUT</p>
<p>2017-07-11 00:55:12.146 SDWebImageSOQuestion INFO: Image
cached successfully!</p>
</blockquote>
<p>希望对你有帮助</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - SDImageCache - 4.0 迁移后无法识别的选择器错误,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/45020422/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/45020422/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - SDImageCache - 4.0 迁移后无法识别的选择器错误