获取SDWebImage缓存在本地的图片

-(UIImage*)imageFromSdcache{

NSData*imageData =nil;

BOOLisExit = [[SDWebImageManagersharedManager]diskImageExistsForURL:[NSURLURLWithString:self.status.focus_pic]];

if(isExit) {

NSString*cacheImageKey = [[SDWebImageManagersharedManager]cacheKeyForURL:[NSURLURLWithString:self.status.focus_pic]];

if(cacheImageKey.length) {

NSString*cacheImagePath = [[SDImageCachesharedImageCache]defaultCachePathForKey:cacheImageKey];

if(cacheImagePath.length) {

imageData = [NSDatadataWithContentsOfFile:cacheImagePath];

}

}

}

if(!imageData) {

imageData = [NSDatadataWithContentsOfURL:[NSURLURLWithString:self.status.focus_pic]];

}

UIImage*image = [UIImageimageWithData:imageData];

returnimage;

}

你可能感兴趣的:(获取SDWebImage缓存在本地的图片)