我面临的问题是我不能使用SDWebImage库的完成块(用Objective编写)。我在几个地方使用sd_setImageWithURL,但是每次我收到错误使用未声明类型'SDImageCacheType‘时。这一问题发生在两个不同的MacBooks上。我检查并在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
};Podfile
pod 'SDWebImage's'
use_frameworks!发布于 2015-11-02 07:21:43
好吧,那是个很小的问题,我不知道为什么我不早点解决。我所需要做的就是添加一个导入。看起来,如果使用声明的块,则需要添加它。
import SDWebImage https://stackoverflow.com/questions/32483112
复制相似问题