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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:14:30+00:00 2026-05-25T10:14:30+00:00

Hi I do have a problem with my Core Data storage! I delete it

  • 0

Hi I do have a problem with my Core Data storage!
I delete it the following way like I found it here an stack overflow:

 NSFetchRequest * allFriends = [[NSFetchRequest alloc] init];
[allFriends setEntity:[NSEntityDescription entityForName:@"Friend" inManagedObjectContext:self.managedObjectContext]];
[allFriends setIncludesPropertyValues:NO]; //only fetch the managedObjectID

NSError * error = nil;
NSArray * friends = [self.managedObjectContext executeFetchRequest:allFriends error:&error];
[allFriends release];
//error handling goes here
for (NSManagedObject * Friend in friends) {
    [self.managedObjectContext deleteObject:Friend];
}

this seams to work perfect at runtime!
my tableview (which I manage with NSFetchedResultsController) clears and all is fine it looks!
Also when I hit the home button and start it back up it works.

BUT if I even close it from the multitasking list (so completely close it) and start it back up all is back in the tableView again!

could anybody help me out with this?

  • 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-25T10:14:30+00:00Added an answer on May 25, 2026 at 10:14 am

    Your code is fine but you have forgotten to commit all changes (objects were removed) made to database. So, you should add following lines to your code and after reopening the app your db will not contain that objects:

        NSError *error;
        if (![self.managedObjectContext save:&error]) 
        {
            // Update to handle the 
            NSLog(@"Unresolved error %@", error);
            exit(-1);  // Fail
        }
    

    Because all changes are stored in memory, don’t forget to save the managed object context after some important or critical changes were made. Before you commit your changes, the database/presistent-store file will be in the previously saved state.

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

Sidebar

Related Questions

I have an iphone app that uses Core Data to do storage. I have
I have a problem with Core Data which has left me at the end
I think I have a problem, maybe linked to a retain cycle in Core-Data.
Lets say I have a core data model like this one: Item attributes: name
I have a navigation based app that uses Core Data for storage. The schema
I'm new to iphone development and have this problem with Core Data. At the
I have a problem I cannot solve with a Core Data entity. In my
I have the following entities in core data as shown in the figure below.
I have a S#arp MVC application with following projects/layers : Core (Model) Data Web
I have an iPhone app that uses core.data as its storage and a rest

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.