0

I'm currently trying to create a core data model which consists of an array of a custom class/struct. I'm free to chooses either class or a struct for the model.

The Struct looks a little bit like this:

public struct takenImage{
  var image: UIImage
  var label: String
  var time: NSDate
}

now I have my Core Data Model which has an entity called LogPhotos containing the attributes:

timestamp of type Date

pictureArray of type Transformable

Now I would like to have my pictureArray contain an Array of the takenImage struct. This is important because I need to call later for certain values from that struct. It's neccessary to get the image from that array for instance.

The issue is, that when I try to save the context it crashes with SIGABRT and uncaught exeption 'NSInvalidArgumentExeption' reason [myApp.takenImage:] unrecognized selector sent to instance I guess it's because it cannot store the [takenImage] to the transformable.

What could I do? I'd like to avoid having another core data entity if possible. Thank you all in advance.

Paco89
  • 25
  • 8
  • Why are you avoiding another entity? This is the sort of thing that would fit perfectly into another related entity. – Abizern Aug 25 '17 at 14:24
  • Please check this https://stackoverflow.com/questions/37980432/swift-3-saving-and-retrieving-custom-object-from-userdefaults – Vini App Aug 26 '17 at 08:20
  • @Abizern The issue is that i'd like to store the images directly in the struct instead of storing the url in the coredata model. – Paco89 Aug 29 '17 at 10:25
  • Performance will be a lot better if you don't have to load the image when the fault fires. – Abizern Aug 29 '17 at 10:35

0 Answers0