I am using core data for my application. I don't have exact idea how can I set primary key and foreign key relationship. And how to insert data accordingly.
CoreData isn't a Database. It's an object persistence layer. There is no concept of primary keys or foreign keys in CoreData.
If you want to establish a relationship between two entities. You'll define a relationship, CoreData takes care of how that relationship is stored.
Select an entity, use plus button at the bottom of the entities attributes list, select add relationship, select the destination entity from the dropdown.
Select the destination entity and define an inverse relationship in the same way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With