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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:52:40+00:00 2026-05-20T13:52:40+00:00

I have a UITableView that is controlled by a NSFetchedResultsController. Rows are organised into

  • 0

I have a UITableView that is controlled by a NSFetchedResultsController.
Rows are organised into sections from a property of the row. But when I modify that property the application terminated with:

Invalid update: invalid number of sections.

Each row represents a shot in a film, wide shot, close up etc..
The row also contains which scene it belongs to and the sections are calculated from that.

Shot.m (CoreData entity)

#pragma mark Transient properties

- (NSString *)sectionIdentifier 
{
    return [self sceneNumber];
}

ShotsViewController.m (The UITableView)

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    id <NSFetchedResultsSectionInfo> theSection = [[self.fetchedResultsController sections] objectAtIndex:section];
    return [theSection name];
}

I don’t know what i’m supposed to do here. I’ve played around with the UITableView insertSections and deleteSections but I always get same invalid number of sections error.

Edit

it moves automatically to other existing sections:

- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
           atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {

    switch(type) {
        case NSFetchedResultsChangeInsert:
            [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeDelete:
            [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;

        case NSFetchedResultsChangeUpdate:
            [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }
}

It worked after I added the

case NSFetchedResultsChangeUpdate:
                [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];

But now, say i’ve got two cells.
Cell1.sceneNumber = 1
Cell2.sceneNumber = 2

If I set Cell1.sceneNumber = 3 I get the error:

Invalid update: invalid number of sections.  The number of sections contained in the table view after the update (3) must be equal to the number of sections contained in the table view before the update (2)
  • 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-20T13:52:41+00:00Added an answer on May 20, 2026 at 1:52 pm

    We’d need to see a lot more code to know what the problem is. However, one thing that might be useful is checking out the “Mastering Table Views” video from last year’s WWDC. They go over the specifics of how to add/remove sections/rows and the order which you should make the change in your model/table (with clear diagrams).

    Go to https://developer.apple.com/videos/wwdc/2010/ and after logging in, go to Application Frameworks > Session 128 – Mastering Table Views.

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

Sidebar

Related Questions

I have a UITableView that updates from a NSFetchedResultsController . The UITableView has alternating
I have a UITableView that gets populated from CoreData via a controller that implements
I have a UITableView that uses custom cells, loaded from nibs, and hooked up
I have a UITableView cell that is going to have a variable size depending
In an app I'm working on, I have a plain style UITableView that can
I am populating a UITableViewController with an NSFetchedResultsController with results creating sections that populate
I have a custom UITableView cell that sports an Image, and a headline. I
Sorry but I found no clear answer on that. I have an iphone app
I have a fairly simple iPhone app that downloads a set of UITableView results
i have all that data with me in tableview but when i dont know

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.