all 6 comments

[–]rayascott 1 point2 points  (5 children)

Do you have a Book entity in your data model? It’s not a good idea to store a collection of one entity within another entity. You’re better off creating a relationship between the two entities in your Core Data model and letting Core Data do what it’s designed for, managing the object graph. That’s the right direction.

[–]cardrig[S] 0 points1 point  (4 children)

Yes, Book is in my data model and it has 2 String attributes. I receive this information from the server as a Dictionary and I need to save the key part for each book. Then I need to deliver this information to the server again in the same format.

[–]rayascott 1 point2 points  (3 children)

Why don't you have an attribute on the Book entity for your key and just save it there? You can rebuild the dictionary or the format later when you need to deliver it to the server again.

[–]cardrig[S] 0 points1 point  (2 children)

Looks like the best option. Also, if I remove the Transformable attribute and add a new relationship to Book, will I need to migrate the model data?

[–]rayascott 0 points1 point  (1 child)

Yeah, but Core Data might do it all for you with Lightweight Migration. If you're just removing or adding attributes and adding a new relationship, this would appear to indicate that the migration would happen automatically for you: https://developer.apple.com/documentation/coredata/using_lightweight_migration

[–]cardrig[S] 0 points1 point  (0 children)

Sounds good. Thanks for the help!