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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:22:39+00:00 2026-05-25T02:22:39+00:00

Why is [NSFetchedResultsController performFetch:] crashing when recreating an NSFetchedResultsController with an equivalent NSFetchRequest ?

  • 0

Why is [NSFetchedResultsController performFetch:] crashing when recreating an NSFetchedResultsController with an equivalent NSFetchRequest?

I have an app that has a table view controller of threads (message threads). When you tap a thread it loads another table view controller that uses an NSFetchedResultsController to get all the messages of that thread and display them. I use an NSFetchedResultsController because I can load the messages in the background/delete/add new ones and not worry about displaying them at all.

The second table view controller is used for all the threads, so when I tap back then tap another thread I just delete the current NSFetchedResultsController and set up a new one for the new thread.

Here are the steps to reproduce the CRASH:

  1. Tap a thread so it shows me the messages.
  2. Reload the messages, so the NSFetchedResultsController gets used to show new messages.
  3. Go back.
  4. Tap another thread.
  5. Go back.
  6. Tap first thread.

On tapping the NSFetchedResultsController gets created that is identical to the very first one. (Same cache and everything). Instead of working like it should it gives this error and crashes:

Program received signal: “EXC_BAD_ACCESS”.

NSFetchedResultsController is sending a message to a freed object.

Here is the stack trace:

#0  0x95ffd688 in objc_msgSend
#1  0x0060699b in -[NSFetchedResultsController(PrivateMethods) _computeSectionInfo:error:]
#2  0x00601bf0 in -[NSFetchedResultsController performFetch:]
#3  0x0001c170 in -[CMNewMessagesViewController loadMessagesViewControllerForThread:showProfile:] at CMNewMessagesViewController.m:331

3 is my method

Any Ideas at all? Any help would be much appreciated.


SOLVED!

It was my fault. I was using a sectionNameKeyPath that was derived from another key-value. That is ok as long as the NSFetchRequest is sorted by that key-value. The problem was that it was dynamically generated since I didn’t want to waste space in the DB for it. I used an instance variable in the NSManagedObject class for it that was cleaned up by didTurnIntoFault.

Now, I think that the instance variable must have been created then discarded then recreated at some point bringing the sorting of NSFetchedResultsController to a grinding halt.

This explains why not having a sectionNameKeyPath or delegate solved the problem.

Now, I’ve switched to a saved key-value in the CoreData Object and it seems to work just fine.

  • 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-25T02:22:40+00:00Added an answer on May 25, 2026 at 2:22 am

    It was my fault. I was using a sectionNameKeyPath that was derived from another key-value. That is ok as long as the NSFetchRequest is sorted by that key-value. The problem was that it was dynamically generated since I didn’t want to waste space in the DB for it. I used an instance variable in the NSManagedObject class for it that was cleaned up by didTurnIntoFault.

    Now, I think that the instance variable must have been created then discarded then recreated at some point bringing the sorting of NSFetchedResultsController to a grinding halt.

    This explains why not having a sectionNameKeyPath or delegate solved the problem.

    Now, I’ve switched to a saved key-value in the CoreData Object and it seems to work just fine.

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

Sidebar

Related Questions

I have a table view that is managed by an NSFetchedResultsController. I am having
I'm using NSFetchedResultsController for my table view. I call -performFetch inside my controller's -viewDidLoad
I have noticed that a problem in my app is caused because the Datasource
I'm developing an iPhone app where I use a NSFetchedResultsController in the main table
I have a tableview that is successfully incorporating an NSFetchedResultsController. However, I need the
I have an app using tableview and NSFetchedResultsController. I am getting the error: Serious
I'm currently working on an App that has a couple of Entities and relationships
I have a DataModel that has a Category, SubCategory, and DetailedItem entities. Category has
Example I have NSFetchedResultsController called at ListController called FetchController +(NSFetchRequest * )fetchRequestInContext: (NSString*) entityName
I have a UISearchBar that is hooked up with a NSFetchedResultsController . It searches

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.