DPImageCache - UIImageView 扩展


未知
iOS
Swift

软件简介

DPImageCache 是 Swift 写成的 UIImageView 的扩展,帮助加载图像异步存储本地文件缓存。

使用:

let dirName = "cache"
func createCacheDirectory() {
        var fileMan = NSFileManager.defaultManager()
        var cacheDir = (NSSearchPathForDirectoriesInDomains(
            .DocumentDirectory,
            .UserDomainMask, true)[0] as! NSString)
            .stringByAppendingPathComponent(dirName)
        if !fileMan.fileExistsAtPath(cacheDir) {
            fileMan.createDirectoryAtPath(
                cacheDir,
                withIntermediateDirectories: false,
                attributes: nil,
                error: nil)
        }
    }