I want to parse these small avatar images to core data, I have this function using AlamofireImage.
However, on the setting of the result to the core data property, I get this error.
Cannot assign value of type 'Data?' to type 'NSData?'
Here is my code:
self.managedObjectContext = self.coreDataManager.managedObjectContext
let contactAvatar = UIImagePNGRepresentation(image);
contact.avatar = contactAvatar
do {
try self.managedObjectContext?.save()
} catch {
fatalError("Failure to save context: \(error)")
}
My Core data entry is Binary Data. I thought I should be able to save to this format correctly?
There are two options:
avatar
as Data
in the model (preferable)contactAvatar as NSData