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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:57:24+00:00 2026-05-17T06:57:24+00:00

I am having problems with the context in Core Data not being able to

  • 0

I am having problems with the context in Core Data not being able to save.

I get random crashes when I try to call [context save:]. Sometimes it works, sometimes it doesn’t and crashes the app. Here is my delete code. I have been able to reduce the number of crashes by checking if [context respondsToSelector] save. The strange this is even when it fails (respondsToSelector fails), and I didn’t call save, it still gets deleted!? But also when the respondsToSelector succeeds, and I attempt to call save, it still crashes sometimes. So the code is a little more stable with the test, but I think there is something wrong with Core Data and the save method. It has been very hard to track down the problem because it really does seem random.

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the managed object.
        NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
        Accidents* accidentDelete = [self.fetchedResultsController objectAtIndexPath:indexPath];
        [context deleteObject:accidentDelete];

        // Causing crash...
        NSError *error = nil;

        if ([context respondsToSelector:@selector(save:)])
            if (![context save:&error]) {
                // Update to handle the error appropriately.
                NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
                exit(-1);  // Fail
            }
        else
            NSLog(@"Error! Context does not respond to save!");   
    }
} 
  • 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-17T06:57:25+00:00Added an answer on May 17, 2026 at 6:57 am

    I’m assuming that crash means — EXC_BAD_ACCESS. If not, please post the exception you are getting and the stack trace.

    EXC_BAD_ACCESS happens because you are accessing bad memory. Usually this is because you are accessing freed memory. The easiest way to track that down is to turn on zombies — this makes all deallocs do nothing, but when you access an object that has had dealloc called on it, it will complain in the console, with the exact point that you are access a freed object.

    I explain a lot more about EXC_BAD_ACCESS here, with some troubleshooting instructions (and instructions for turning on zombies)

    http://www.loufranco.com/blog/files/Understanding-EXC_BAD_ACCESS.html

    Go to Project->Edit Active Executable, go to the Arguments tab and in the environment variables section, add

    NSAutoreleaseFreedObjectCheckEnabled 
    NSZombieEnabled    
    NSDebugEnabled 
    

    And set each to YES. You can leave them there unchecked, but if you check them, then your application will now do some extra checking on autorelease and release and give you a good stack trace when you have done it wrong. A common problem is to think you need to call release when the object is already set to autorelease (see yesterday’s post on what the rules are for that).

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

Sidebar

Related Questions

I am having some problems comparing the elements in different cell arrays. The context
im having problems on how to save the content of an array in an
I'm having a lot of issues with trying to perform some core data operations
I'm having problems with a project deployment. Here's the error i get: 01:08:26,780 ERROR
I'm having a problem with Core Data. I have two Entities (Article and Manufacturer)
I'm having problems when I try to login with JSF 2. I am getting
I am new to jquery mobile, and am having problems getting content I have
I am having problems getting my main content div to stretch to full height,
I am having problem with qtip content button. When i try to change a
I'm having a problem that a statusbar get displayed over the content of the

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.