Swift Core Data Relationship to Same Entity

Hello,


i'm new to Swift Programming and I'm struggling with Core Data a bit.

My Data Model looks like the following:

I have Items with multiple values like id, name, description, etc... nothing special, BUT Items can have "parts" that they are made of.

For example:

  • Item1
    ID: 1
    Name: One
    Parts:
    • Subitem1
      ID:2
      Name: SubOne
    • Subitem2
      ID: 3
      Name: SubTwo
      Parts:

      Subsub1
      ID:4
      Name: SububTwo

  • Item2
    ID: 5


The setup in the xcdatamodelc is fairly simple, but i don't actually know how to fill it with data and save it.

The data comes from a mysql database (there is a column "isPartOf" which specifies the parent-child relationship).

I haven't found any resource on google which is addressing a similar setup, can anyone help me with my problem or knows Links/Books with information that can help me?


Thank you

Swift Core Data Relationship to Same Entity
 
 
Q