Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relationship to self in Core Data

I want to create friends list in my core Data. I have entity User with relationship friends. My user have attributes (to simplify):

  • userId
  • name

I want that he can make friends so i add this relationship:

enter image description here

All friends of course will be have the same pair of attribute.

So when i look into graph i see something like this:

enter image description here

This is correct ? Can i managed it like separate entity? Will creating a new friend create a new user? What is keyword for apple documentation to find an example or description of this behavior?

like image 745
Jakub Avatar asked Oct 22 '25 14:10

Jakub


1 Answers

The relationship is absolutely correct, except that friendship is naturally bidirectional, so inverse relation is friends too. There is no such issue as creating a friend, so it not creates a new user. You can just build a friendship relation between two existing users. The keyword you are looking for is : Core Data Programming Guide :)

like image 126
imihaly Avatar answered Oct 25 '25 05:10

imihaly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!