0

I want to be able to save an array to core data. I am aware that this can't be done.

In this case, I have an entity named 'List' and an attribute called 'items'. You can see why an array would be helpful, I am able to save it with the Transformable type as an NSObject, but I can't access the individual elements once it has been pulled out of core data as an NSObject.

Can anybody tell me either how to go about saving an array in Core Data or how to use my NSObject to fix my problem

Matt Spoon
  • 2,760
  • 5
  • 25
  • 41

1 Answers1

1

You do not want to save an array to Core Data, you want to create an entity called Item (or even ListItem) that has a one to many relationship with your entity called List. You would call the one -> many (List -> ListItem) property items and the many -> one (ListItem -> List) would be called list.

From there you can access both sides of the relationship via those properties.

That is how you should be handling this situation in Core Data.

Marcus S. Zarra
  • 46,571
  • 9
  • 101
  • 182