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

  • SEARCH
  • Home
  • 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 7185737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:28:51+00:00 2026-05-28T18:28:51+00:00

I have an NSManagedObject that has a to-many relationship to another NSManagedObject. During creation

  • 0

I have an NSManagedObject that has a to-many relationship to another NSManagedObject.

During creation of the NSManagedObject I can use the generated accessors ‘removeNotesObject’ and the deletion works fine. I can create an object to add to the parent object, save the object, delete the object and then save again. When I fetch this parent object the object I created and deleted is still deleted.

However, after I add the object and then save it (but don’t delete and save after) and then fetch it, I can’t seem to delete the object that was previously created. I am using the generated accessors to try and remove the object, which appears to work but when I fetch it again the object hasn’t been deleted.

(Note: Adding objects does work so it is not a problem with the saving)

To delete the object I retrieve the set of object and select the objects I want to delete. Then I remove the objects

NSSet *notes = summary.notes;
NSSet *oldNotes = [notes objectsPassingTest:^(id obj,BOOL *stop){
    Note *oldNote = (Note *)obj;
    BOOL sameRow = (oldNote.row == newNote.row);
    BOOL sameColumn = (oldNote.column == newNote.column);
    BOOL success = (sameRow && sameColumn);
    return success;}];
[summary removeNotes:oldNotes];

I have tried making the relationship inverse to delete the objects which didn’t delete them. I have also tried different delete rules (cascade and nullify) which again didn’t work. Finally, I tried to remove each object separately and deleting each object from the context after I had removed it from the parent object which again unfortunately didn’t work.

I assume the problem must be something to do with it being a fetched object. If anyone could help I would really appreciate it as I can’t think of any other ways to test or solve this problem.

  • 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-28T18:28:52+00:00Added an answer on May 28, 2026 at 6:28 pm

    The reason the above code did not work is that == will not actually compare the NSNumber. Instead you need to call ‘isEqualTo:’. I think before it was checking the address hence working before I saved it. What’s more it was returning an object in the NSSet so appeared to be working. During debugging it wasn’t clear what the object was but clearly wasn’t the one I needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NSManagedObject who has a one to many relationship with the parent
So my problem is that I have a NSManagedObject 'A' which has a has-many
I have a managed object subclass named Tag that has a to-many relationship to
I have a CoreData NSManagedObject subclass, TextNarration, that has an attribute of type NSString,
I have a subclassed NSManagedObject that conforms to the MKAnnotation protocol and it has
I have two core data entities, Articles and Favorite . Articles has To-Many relationship
i have an NSManagedObject that has just attributes(no fetched properties or relationshiops). I retain
I have a Department entity which has a one-to-many relationship to an Employee entity.
I have a ConfiguracaoDaApp class in my project that is a NSManagedObject subclass. I
I have 3 entities like this: sorry that this image has a problem that

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.