I've succeeded in incorporating SDWebImage
(written in Objective-C
) with my Swift
project - but its still acting a bit funny. Specifically, its giving me an error in the if
statement inside the following Closure
:
let completionBlock: SDWebImageCompletionBlock! = {
(image:UIImage!, error: NSError!, cacheType:SDImageCacheType, imageURL:NSURL!) -> Void in
if (image && cacheType == SDImageCacheType.SDImageCacheTypeNone) {
cell.productImageView.alpha = 0.0
UIView.animateWithDuration(1.5, animations: {
cell.productImageView.alpha = 1.0
})
}
}
cell.productImageView.sd_setImageWithURL(imageURL!, placeholderImage:UIImage(named:"Icon120pix.png"), completed: completionBlock)
The error I'm getting on that if statement is: Use of unresolved identifier 'SDImageCacheTypeNone'
This makes no sense because SDImageCacheTypeNone
is one of the values defined in the SDImageCacheType typedef
.
By the way, if I take that if
statement out and leave just the statements inside it, everything works just fine.
So any ideas what I might be doing wrong here?
SDImageCacheType
, and its values areSDImageCacheTypeNone
,SDImageCacheTypeDisk
, andSDImageCacheTypeMemory
. So because each value contains the name of the typedef itself you just use the part that's different? MeaningNone
,Disk
, andMemory
? Or is Objective-C like that too and I just didn't know that?