Search code examples
swiftxcodecore-data

Can an entity have a list/array of items (Core Date, XCode)


I'm very new to Core Data and I have two questions:

  1. I want that all of my Patient entities have property bed which is a value of type bed... Can I create an entity for that too and connect always one patient with one bed?

  2. I wondered if I can do something like every Patient has a property doctors, and that would be a array of doctors "[doctor]". How could I make this.

Thanks, hope you know what I mean, it would be great If someone knows how to do that.


Solution

  • Okay Larme and Joakim Danielson answers my question as comments under my post :) Their comments:

    Yes. The key word you are missing is "relations". You want relationship between your entities. Be it one to one, one to many, many to many. –

    Find an online tutorial on learning and using Core Data, many of them handles entity relationships as well –