A
A
Aleksandr Govorukhin2017-06-07 17:38:58
Swift
Aleksandr Govorukhin, 2017-06-07 17:38:58

How to unzip NSKeyed images from CoreData in CollectionView swift 3?

Hello!
There is a function with which I saved all downloaded images:

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)

How now to unzip and assign these pictures to UIImageVIew?
In CoreData they are in the image attribute: Binary Data
Help a newbie =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksandr Govorukhin, 2017-06-07
@SnapSh0t

let images = NSKeyedUnarchiver.unarchiveObject(with: recipe.imageRecipe! as Data) as! NSMutableArray
        
        let img = UIImage(data: images[indexPath.row] as! Data)!
        
        cell.recipeImageView.image = img

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question