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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:51:28+00:00 2026-05-23T17:51:28+00:00

In my iPhone app, I have a UITableView with the following method – (NSInteger)numberOfSectionsInTableView:(UITableView

  • 0

In my iPhone app, I have a UITableView with the following method

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [tableArrays count];
}

Note that tableArrays is a class variable (an NSMutableArray of NSMutableArrays – representing one NSMutableArray for each section in my tableView). Now, that UITableView supports editing, and I have the following method

- (void)tableView:(UITableView *)theTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    ...some code...

    NSLog(@"tableArrays count is %i",[tableArrays count]);
    [tableArrays removeObjectAtIndex:indexPath.section];
    NSLog(@"tableArrays is now %@",tableArrays);
    NSLog(@"tableArrays count is now %i",[tableArrays count]);


   [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

}

So, I run the app and I have two sections in my table view. Row deletion works fine except when I delete the last row in a section. When I delete the last row of section 1, I see the following output, as per the code above:

tableArrays count is 2
tableArrays is now (("Blah1","Blah2"))
tableArrays count is now 1

So clearly, my tableArrays count decreases by one, but I get the following error:

...The number of sections contained in the tableView after the update (1) must be qual to the number of sections contained in the table view before the update (2), plus or minus the number of sections inserted or dleted (0 inserted, 0 deleted).'
  • 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-23T17:51:28+00:00Added an answer on May 23, 2026 at 5:51 pm

    I guess in -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; you are returning the total count of objects and you want to display only one section.

    Try returning one in this method.

    You should also return [tableArrays count]in -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;.

    It should work better like this. Also what is section in

    [tableArrays removeObjectAtIndex:section]; ? Did you mean indexPath.section ?

    Thank for the comment, so the method that is returning the number of section is correct, but you to do like that to delete a cell.

    NSLog(@"tableArrays count is %i",[tableArrays count]);
    NSMutableArray *sectionArray = [tableArrays objectAtIndex:indexPath.section];
    [sectionArray removeObjectAtIndex:indexPath.row];
    //[tableArrays removeObjectAtIndex:indexPath.section];
    NSLog(@"tableArrays is now %@",tableArrays);
    NSLog(@"tableArrays count is now %i",[tableArrays count]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my iPhone app I have a UIViewController that has a UITableView and another
I have a fairly simple iPhone app that downloads a set of UITableView results
I have an iPhone app that hides the status bar. However, my main view
I have a simple iphone app that's based on the CrashLanding sample app. So
I have an iPhone app that compiles and runs fine in the Simulator on
I'm working on a view-based iPhone app that has the following flow: search ->
On my iphone app, I have a UITableView in edit mode, containing custom UITableViewCell.
I have an iPhone app that grabs information from different sources in XML format.
Sorry but I found no clear answer on that. I have an iphone app
On my iphone app, I have a UITableView in edit mode, where user is

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.