2

My swift code below is trying to fetch a numbered core data binary array. I am getting the error Cannot assign value of type 'UIImage' to type 'Data?' at piczy[I].This code works if I take the core data from a string but doing this with a image it does not work and causes a compile error. Users is the name of core data entity.

enter image description here

  class ViewController: UIViewController{
   var piczy = [UIImage]()
    func fetch()
    {

          for i in 0..<piczy.count {
            let newUser = Users(context: context)
            newUser.image = piczy[i]
            newUser.idxPic = Int32(i + 1)

        }
  }}
  • Try changing your image entity type from `Binary Data` to `Transformable` then `for image in piczy {` `newUser.image = image` `}` – Leo Dabus Jan 19 '20 at 03:01
  • That does work but does transformable data work on photos. Can I load transformable data to display on image view. –  Jan 21 '20 at 05:04

0 Answers0