SDWebImage 找不到 SDImageCacheType

SDWebImage cannot find SDImageCacheType

我面临无法使用 SDWebImage 库(用 Objective-C 编写)的完成块的问题。我在几个地方使用了 sd_setImageWithURL,但每次我收到错误 Use of undeclared type 'SDImageCacheType'。该问题出现在 2 台不同的 MacBook 上。我检查了一下,缺少的类型在 SDWebImage.h 文件中声明(附在最后)。我正在使用 CocoaPods。

基本源代码

        imageViewMain.sd_setImageWithURL(NSURL(string: finalURL)) //Works fine

        // Doesn't work.
        let b : SDImageCacheType = SDImageCacheType.None
        let block = {(image: UIImage!, error: NSError!, cacheType: SDImageCacheType.None, imageURL: NSURL!) -> Void in
            println(self)
        }
        imageViewMain.sd_setImageWithURL(NSURL(string: finalURL), completed: block)

新娘头必备线

#import <SDWebImage/SDImageCache.h>

SDImageCache.h 文件的顶部

/*
 * This file is part of the SDWebImage package.
 * (c) Olivier Poitrey <rs@dailymotion.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

#import <Foundation/Foundation.h>
#import "SDWebImageCompat.h"
typedef NS_ENUM(NSInteger, SDImageCacheType) {
    /**
     * The image wasn't available the SDWebImage caches, but was downloaded from the web.
     */
    SDImageCacheTypeNone,
    /**
     * The image was obtained from the disk cache.
     */
    SDImageCacheTypeDisk,
    /**
     * The image was obtained from the memory cache.
     */
    SDImageCacheTypeMemory
};

播客文件

pod 'SDWebImage's'
use_frameworks!

好吧,这是一个非常微不足道的问题,我不知道为什么我没有早点弄清楚。我需要做的就是添加一个导入。看起来如果你使用声明的块你需要添加它。

import SDWebImage