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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:49:37+00:00 2026-05-14T00:49:37+00:00

I have a Core Data based mac application that is working perfectly well until

  • 0

I have a Core Data based mac application that is working perfectly well until I save a file. When I save a file it seems like something changes in core data because my original fetch request no longer fetches anything. This is the fetch request that works before saving but returns an empty array after saving.

NSEntityDescription *outputCellEntityDescription = [NSEntityDescription entityForName:@"OutputCell" 
                                                                   inManagedObjectContext:[[self document] managedObjectContext]];
NSFetchRequest *outputCellRequest = [[[NSFetchRequest alloc] init] autorelease];
[outputCellRequest setEntity:outputCellEntityDescription];
NSPredicate *outputCellPredicate = [NSPredicate predicateWithFormat:@"(cellTitle = %@)", outputCellTitle];
[outputCellRequest setPredicate:outputCellPredicate];
NSError *outputCellError = nil;
NSArray *outputCellArray = [[[self document] managedObjectContext] executeFetchRequest:outputCellRequest 
                                                                                 error:&outputCellError];

I have checked with [[[self document] managedObjectContext] registeredObjects] to see that the object still exists after the save and nothing seems to have changed and the object still exists. It is probably something fairly basic but does anyone know what I might be doing wrong? If not can anyone give me any pointers to what might be different in the Core Data model after a save so I might have some clues why the fetch request stops working after saving?

Edit

I have got as far as working out that it is the relationships that seem to be breaking after a save. If I omit the lines setting a predicate for the request, the request returns objects in the array. I have checked through the registeredObjects and it appears that the relationships are intact, but if I do something like save a file, re-open it and then check the registeredObjects the relationships are set to nil. I’ve opened a save file as an xml file and the relationships appear to be intact when the file is first saved.

I’ve added a screen shot of the part of the core data model were the relationships are broken. Does anyone have any idea why saving a file in core data might break the relationships? For reference I’m using the default implementation of save built into core data so there is no custom save code.

http://emberapp.com/splash6/images/littlesnapper/sizes/m.png

Edit

I have no -awakeFromFetch: methods that are triggering when this problem is caused.

I have sub-classed NSManagedObject for some of the problem objects, using the Core Recipes model for KVO:

    +(void)initialize
{
    if (self == [OutputCell class])
    {
        NSArray *nameKeys = [NSArray arrayWithObjects:@"cell", @"sheet", @"table", nil];
        [self setKeys:nameKeys
        triggerChangeNotificationsForDependentKey:@"cellTitle"];

        NSArray *measuresKeys = [NSArray arrayWithObjects:@"fivePercentile", @"maximum", @"mean", @"median",@"minimum",@"ninetyFivePercentile",@"standardDeviation",nil];
        [self setKeys:measuresKeys
        triggerChangeNotificationsForDependentKey:@"analysisResults"];
    }
}

This method doesn’t seem to be firing during or after a save so it doesn’t seem to be this that is causing the problem. I’m currently going through all the other methods in the code to find if any of them happen to get called during or after a save.

Edit

Following on from Marcus’ suggestion below I’ve managed to make a fetch request fail before the model is saved. My problem now is the message this getting returned in the console when it fails:

HIToolbox: ignoring exception '+entityForName: could not locate an NSManagedObjectModel for entity name 'OutputCell'' that raised inside Carbon event dispatch

The console message is logged following this call:

NSEntityDescription *outputCellEntityDescription = [NSEntityDescription entityForName:@"OutputCell" 
                                                               inManagedObjectContext:[[self document] managedObjectContext]];

Should the extra ‘ following the OutputCell in the console message be there? Do objects normally have this extra ‘, or has it come from somewhere? If it has come from somewhere and is causing the fetch request to fail, does anyone have any bright ideas where this might have come from or how I might track it’s source down?

  • 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-14T00:49:37+00:00Added an answer on May 14, 2026 at 12:49 am

    Sounds like you are setting something to nil somewhere and causing you to get nil back. I would walk through your save and fetch code in the debugger and look for objects being set to nil when you do not expect it.

    update

    Do you have any code anywhere that can be manipulating the relationships? Perhaps something in the -awakeFromFetch: that is causing the relationships to get corrupted?

    If they are saving correctly the first time and then failing then that truly points at something in your code corrupting those relationships. Are you subclassing NSManagedObject for these objects? If so are you by chancing overriding the -init... method?

    update

    That last tick should definitely not be there. Check your fetch request, this might all boil down to a simple typo in a string somewhere…

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

Sidebar

Related Questions

I have a Core Data based application that stores hierarchal data displayed using a
I have a document-based Core Data application (running on Mac OS X 10.5 and
I have a non document-based Core Data application. There's an NSTreeController that manages a
I have a core data based app I am working on, that uses an
I have a core data based app that manages a bunch of entities. I'm
I have this issue with Core Data. I am creating a core-data-based application, for
Environment: xcode 3.2.1, document-based core-data application. I have a document-based cocoa app which uses
I have an application based on the Core Data Books example, and I'm coming
I'm a nwebie in Core Data, i have designed a navigation based application and
I'm working on a Core Data based application (I'm used to work with sqlite,

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.