NSData *imageData = nil; BOOL isExit = [[SDWebImageManager sharedManager] diskImageExistsForURL:[NSURL URLWithString:imageURL]]; if (isExit) { NSString *cacheImageKey = [[SDWebImageManager sharedManager] cacheKeyForURL:[NSURL URLWithString:imageURL]]; if (cacheImageKey.length) { NSString *cacheImagePath = [[SDImageCache sharedImageCache] defaultCachePathForKey:cacheImageKey]; if (cacheImagePath.length) { imageData = [NSData dataWithContentsOfFile:cacheImagePath]; } } } if (!imageData) { imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]; } return imageData;
原文:http://my.oschina.net/bufenye/blog/525176