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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:15:54+00:00 2026-06-17T06:15:54+00:00

The good facts: I download data from the server, and, via Core Data thread

  • 0

The good facts:

  • I download data from the server, and, via Core Data thread confinement, save the data, and when the background MOC is saved, the main MOC gets merged.
  • All the saving operations go ok
  • Also the merging of the MOC happens without any problems

The bug I’m hunting:

  • When my UITableView with NSFetchedResultsController is active (i.e. on the screen), and the saving is happening, the app crashes with a SIGABRT that takes me to the mergeChangesFromContextDidSaveNotification line in AppDelegate.
  • What is the most strange part is, that when the delegate of the FRC is nil, or when it is my view controller but i don’t implement any FRC delegate methods, the crash doesn’t happen and I don’t have any problem. But when I implement any of the delegate methods (even empty, without a single line of code), the app crashes with the same bug. It means that the methods are not even being fired, the problem is not in the code inside these methods.
  • The strangest part 2 (CHECK UPDATE 2 BELOW): the crash happens with a [__NSCFNumber length]: unrecognized selector sent to instance and I don’t call any ‘length’ property in my CoreDataManager neither in my AppDelegate class

The witness: console

<CoreDataManager.m:(338)> Saved data from server
<AppDelegate.m:(352)> Will merge
<CoreDataManager.m:(338)> Saved data from server
<AppDelegate.m:(355)> Did merge
<CoreDataManager.m:(338)> Saved data from server
<AppDelegate.m:(352)> Will merge
<AppDelegate.m:(355)> Did merge
<CoreDataManager.m:(338)> Saved data from server
<CoreDataManager.m:(338)> Saved data from server
<CoreDataManager.m:(338)> Saved data from server
<MyTableViewController.m:(134)> Fetched results controller did fetch 
<CoreDataManager.m:(338)> Saved data from server
<CoreDataManager.m:(338)> Saved data from server
<CoreDataManager.m:(338)> Saved data from server
<AppDelegate.m:(352)> Will merge
<CoreDataManager.m:(338)> Saved data from server
[__NSCFNumber length]: unrecognized selector sent to instance 0x13318050

Some code – Merging the MOCs

- (void)managedObjectContextDidSave:(NSNotification *)notification
{
    NSManagedObjectContext *sender = (NSManagedObjectContext *)[notification object];

    if ((sender != self.managedObjectContext) &&
        (sender.persistentStoreCoordinator == self.managedObjectContext.persistentStoreCoordinator))
    {
        dispatch_async(dispatch_get_main_queue(), ^{
            DebugLog(@"Will merge");
            [self.managedObjectContext mergeChangesFromContextDidSaveNotification:notification];
            DebugLog(@"Did merge");
        });
    }
}

Update 1

Following Cocoanetics hint, I created a NSNumber category to check who is calling length. I got what you see below, and a crash in [__NSCFNumber _fastCStringContents:]: unrecognized selector sent to instance.

enter image description here

Update 2
Enabling zombies didn’t help =(

  • 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-17T06:15:55+00:00Added an answer on June 17, 2026 at 6:15 am

    Well, after months and hours, I finally got a solution. It works, and I would love to hear some opinions on why.

    So, as I said, the saving was working 100%, as well as the merging notifications. If I set the NSFetchedResultsController delegate to nil, there was no problem. However, setting the delegate to my UIViewController, made the app crash.

    I thought it could be, maybe due to my code when the delegate methods were triggered. But the app crashed even before that. So I followed Cocoanetics tip, to create a category and try to figure out who was calling the length method to the NSNumber object. After that, I saw that the NSPredicate was calling - (BOOL)evaluateWithObject:(id)object; before getting to the crash. In the same way, I did a category to override it:

    @interface NSPredicate (PractiPredicate)
    - (BOOL)evaluateWithObject:(id)object;
    @end
    
    @implementation NSPredicate (PractiPredicate)
    
    - (BOOL)evaluateWithObject:(id)object
    {
        NSLog(@"Evaluate was called. Object class %@", NSStringFromClass([object class]));
        MyManagedObject *myManagedObject = object;
        NSLog(@"Is fault? %d", myManagedObject.isFault);
        NSLog(@"myManagedObject changed and already have propertyA? %d", myManagedObject.propertyA != nil);
        return YES;
    }
    
    @end
    

    So, for my surprise, it worked, and generated te following logs:

    Evaluate was called. Object class MyManagedObject

    Is fault? 0

    myManagedObject changed and already have propertyA? 1

    I decided to print "Is fault?" because I thought that this mess was related to NSManagedObject faulting, but, for what it printed, it’s not.

    Question for the comments: What do you think that could have generated this problem here?

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

Sidebar

Related Questions

Good evening, I have used BeautifulSoup to extract some data from a website as
I want to download a list of topics from server (e.g. 40) and then
I am trying to create a custom enumeration via a series of facts. greater(X,Y)
so I have a set of facts: course(cs61, intro to cs) ... course(cs62b, data
Fact: I'm not that good with jQuery. Problem: I have a form containing dynamically
Good morning, I have mysql queries where I would like to calculate percentage of
Good day. I need to teach Windows CryptoAPI to encrypt the message with private
Good evening guys. I'm currently trying to get started on development of a project
Good Day, Can someone confirm what was said at the bottom of this post
Good day, I have a class that implements the LoaderCallbacks, and hence have 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.