I want to save the UIImage that I get from the UIImagePickerCollector into CoreData attribute "img" that is Binary Data type. I just try to save using following code.
let sampleimage = profileimg?.image
var dataImage: Data? = nil
if let aSampleimage = sampleimage {
dataImage = aSampleimage.jpegData(compressionQuality: 0.0)
}
let imag = Data()
let newUser = NSEntityDescription.insertNewObject(forEntityName: "Person", into: Constant.context!)
newUser.setValue(self.txtName!.text, forKey: Constant.CDName)
newUser.setValue(self.txtEmail!.text, forKey: Constant.CDEmail)
newUser.setValue(self.txtPassword!.text, forKey: Constant.CDPassword)
newUser.setValue(yourDate, forKey: Constant.CDDob)
newUser.setValue(imag, forKey: Constant.CDImage)
When I try to run the it not showing any error. But I don't know image is save in CoreData OR not. How can I check it?
And when I try to assign the image into my table view cell it's show me following error. Please prove proper solution.