Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7193111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:06:09+00:00 2026-05-28T20:06:09+00:00

I have two entities, one called Group and the other called Contact . They

  • 0

I have two entities, one called Group and the other called Contact. They have a many-to-many relationship (with a minimum of one). Thus, at least one contact can belong to one or many groups and at least one group can belong to one or many contacts.

Contact <<-->> Group

Now when I want to update a group I have in my view controller my subclassed NSManagedObject Group available. (@property (nonatomic, strong) Group *selectedGroup;)

Say if group at first has a relationship with 3 contacts, after I updated that group it should have 2 contacts (1 of the original contacts and 1 new contact).

Before update    After Update
Group            Group
-----            -----
ContactA         ContactA
ContactB         ContactD
ContactC

ContactA should stay intact.

This means that ContactB relationship should be removed from the Group (and also should be deleted from the Contact entity since no other group has a relationship with ContactB)

ContactC should be created.

How would I handle this scenario? I can’t get it to work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:06:10+00:00Added an answer on May 28, 2026 at 8:06 pm

    Did you generate model classes for your core data models? If so you should have CoreDataGeneratedAccessors created that look like this in your Group class:

    - (void)addContactObject:(Contact *)value;
    - (void)removeContactObject:(Contact *)value;
    

    You could then do the following:

    Group *group = ...
    Contact *contactB = ...
    Contact *contactC = ...
    Contact *contactD = ...
    [group addContactObject:contactD];
    [group removeContactObject:contactB];
    [group removeContactObject:contactC];
    //save your context
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Preface: I have two entities defined as a one-to-many relationship: A <<-------> B. B's
I have two entities, a User and Role with a one-to-many relationship from user
I have two EF entities. One has a property called HouseNumber. The other has
I have two entities that usually have one-to-many relationship, but in rare cases should
i have two entities one called User and another called Membership which has a
i have two Entities, Parent and Child, that are linked through a bidirectional one-to-many
I've got two entities, one called Site and the other called Assignment. A Site
I have two entities with a Unidirectional Many-to-One mapping. Here's Product : use Doctrine\Common\Collections\ArrayCollection;
I have two Core Data entities: Parent and Child . Parent has to-many relationship
I have two entities referenced one to many. When entity framework created the table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.