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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:27:43+00:00 2026-06-01T14:27:43+00:00

I have a UITableView with several sections, and the number of sections is dynamic,

  • 0

I have a UITableView with several sections, and the number of sections is dynamic, that is, they can increase at any time. Reloading a section with animation on a table view where the number of sections is no big deal. I just call this:

[notesTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];

However, getting this to work when the number of sections changes is such a pain. I always get that typical assertion error "The number of sections in your tableview before the reload must be the same as after the reload..etc". I understand I should use [tableView insertSections...] to get rid of this, but doing this might be difficult in my situation.

My number of sections is based of the size of an array. Is there anyway to reload sections with animations just automatically, as easy as calling [tableView reloadData], without having to worry about inserting rows and sections manually?

(I know a cheap workaround would be to use UIView animations or CAAnimation, but that doesn’t quite give the same effect as reloadSections withAnimation method.)

  • 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-01T14:27:45+00:00Added an answer on June 1, 2026 at 2:27 pm

    This is a common error when you are playing around with FetchedViewControllers. The reason why you are getting that error is because you are deleting objects in your dataSource , and the tableView tries to load the tableView, and looks at the delegateMethods – it shows that you have lesser sections that what is specified.

    You have two options :

    1. Implement the FetchedResultsController delegate methods and implement objectWillChange (or) objectDidChange method, and inside that say something like

      [[self tableView] reloadData]; 
      
      // or
      
      [[self tableView] endUpdates];
      

      That should fix the problem.

    2. Implement notifications (when you delete data under different managedObjectContexts), and post a notification when NSManagedObjectContextDidSave (or) NSManagedObjectContextDidChange. Then you will have to add an observer to MERGE the changes with the notifications. But I doubt your problem is this serious. I would say options (1) should be sufficient.

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

Sidebar

Related Questions

I have a UITableView with each cell being broken into several sections with a
I have a grouped UITableView that contains several cells (just standard UITableViewCell s), all
I have a grouped uitableview which has several sections. The sections are showing up
I have a UITableView that contains several cells and some of them (the ones
I have created an editable UITableView that supports several custom UITableViewCells of my own
I have UITableView that will have several child UITableViews which may also have 1
I've set up a UITableView with several custom UITableViewCell's that have some UITextField's and
I am creating a uitableview that has two sections, section == 0 has 5
I have UITableView that contains many cell. User can expand cell to see more
I have a UITableView that displays single large images in each cell. The names

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.