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 8497971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:16:34+00:00 2026-06-11T00:16:34+00:00

I am deleting a managed object from core data like this: [item.managedObjectContext deleteObject:item]; (Note

  • 0

I am deleting a managed object from core data like this:

[item.managedObjectContext deleteObject:item];

(Note that this item is created, but not saved at this point.)

Trying to fix a bug, I wanted to confirm that the item was indeed deleted. First, since every ‘item’ belongs to a ‘list’, I logged the count of list.items before and after. There was no change. Suspect.

To be doubly sure, I added a fetch request before and after the deletion, and logged the total number of items in the context. This is where it gets weird.

I found that the very act of executing the fetch removed my initial bug. In other words, if I execute a fetch before and after the deletion, I can clearly see that the number of items in the context is reduced by one. However, without this fetch, the item is not deleted (or at least not immediately).

Does anyone have some insight into what is happening here?

  • 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-06-11T00:16:35+00:00Added an answer on June 11, 2026 at 12:16 am

    the deleteObject method doesn’t actually remove the object – it marks it for deletion. The changes aren’t actually made until the changes are committed.

    Edited to add

    To expand on the answer in response to the comments:

    If you want to know if the context has changed so you know when to fire off a fetch request then you can register to observe the NSManagedObjectContextObjectsDidChangeNotification which is sent when an object in the context is sent a deleteObject message.

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

Sidebar

Related Questions

When i am deleting a SMS message from android system, with this code: context.getContentResolver().delete(
What's the best design to use in an iPhone app that uses core data
This has been asked before, but no solution described that is fast enough for
I need some clarification regarding runtime/heap issues when deleting an object which was created
I have a singleton data manager object that manages the connection to a web
I'm facing that problem I've got 2 managed object subclasses connected by a one-to-many
I'm struggling with deleting multiple rows. I'm learning and have managed new rows and
When deleting a record from the database, occasionally I will run into a reference
Locally deleting a file followed by svn update restores the local copy of that
Is deleting a pointer same as freeing a pointer (that allocates the memory)?

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.