ImageCache.default.retrieveImage(forKey: "key_for_image", options: nil) {
image, cacheType in
if let image = image {
print("Get image \(image), cacheType: \(cacheType).")
//In this code snippet, the `cacheType` is .disk
} else {
print("Not exist in cache.")
}
}
var imgArray = [UIImage]();
var CDataArray = NSMutableArray();
for img in imgArray{
let data : NSData = NSData(data: UIImagePNGRepresentation(img))
CDataArray.addObject(data);
}
//convert the Array to NSData
//you can save this in core data
var coreDataObject = NSKeyedArchiver.archivedDataWithRootObject(CDataArray);
//extract:
if let mySavedData = NSKeyedUnarchiver.unarchiveObjectWithData(coreDataObject) as? NSArray{
//extract data..
}