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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:15:11+00:00 2026-05-14T22:15:11+00:00

I have a TableView controller class that uses a fetched results controller to display

  • 0

I have a TableView controller class that uses a fetched results controller to display a list of ‘patient’ entities taken from a Core Data model. The sections of this table are taken from a patient attribute called ‘location’. Here is the sort descriptor for the fetch request:

NSSortDescriptor *locationDescriptor = [[NSSortDescriptor alloc] initWithKey:@"location" ascending:YES];
NSSortDescriptor *lastNameDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:locationDescriptor, lastNameDescriptor, nil];

Here is the initialisation code for the FRC:

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"location" cacheName:@"List"];

When I want to add a new ‘patient’ entity – I click an add button which then pushes an ‘add new patient’ view controller to the navigation stack.

The first patient I add works fine.

If I add a second patient – the app will sometimes crash with the following error:

2010-03-22 14:42:05.270 Patients[1126:207] Serious application error. Exception was caught during Core Data change processing: * -[NSCFArray insertObject:atIndex:]: index (1) beyond bounds (1) with userInfo (null)
2010-03-22 14:42:05.272 Patients[1126:207] *
Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘*** -[NSCFArray insertObject:atIndex:]: index (1) beyond bounds (1)’

This only seems to happen if the patient’s have a location added (if none is added then the location defaults to ‘unknown’). It seems to have something to do with the sorting of the location too. For instance, if the first patient location = ward 14 and the second = ward 9 then it crashes without fail.

I’m wondering if this is something to do with how I am asking the fetched results controller to sort the section names??

This bug is driving me nuts and I just can’t figure it out. Any help would be greatly appreciated!

  • 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-14T22:15:12+00:00Added an answer on May 14, 2026 at 10:15 pm

    This seems to be a bug in Apple’s code. I had some success using this SafeFetchedResultsController subclass.

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

Sidebar

Related Questions

In my tableview have custom cells that I initialize from a UITableViewCell class. I
I have a controller that contains a tableView that spawns another controller modally to
I have a view controller that has a tableView in it. When I set
I am trying to have a tableview that leads to another tableview whose list
I have a UITableView that uses custom cells, loaded from nibs, and hooked up
I have created a controller class named TAddAlarmController which has a tableview which consists
I'd like to have a BaseViewController class (that inherits from UIViewController ) for my
Here is my predicament: I have a tableview controller that loads a detail view
I have a table view controller with (among others) a cell that is to
I have a class that conforms to UISearchDisplayDelegate and contains a UISearchBar. This view

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.