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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:24:14+00:00 2026-06-18T04:24:14+00:00

I have an UITableView which shows the list of pdf files (from Documents folder)

  • 0

I have an UITableView which shows the list of pdf files (from Documents folder) the user saved.

When I try to remove the only row in the table, it works fine.

But when the rows are more than one, and i try to remove the third row, for example, I get..

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

Now, I tried to check whether my array count was > 0, in that case I removed the row, else the indexSet, but without any luck.

This is the code I’m using

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [tableView beginUpdates];

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

        NSError *error;
        NSFileManager *fileMgr = [NSFileManager defaultManager];
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *filePath = [documentsDirectory
                               stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",[self.pdfArray objectAtIndex:indexPath.row]]];
        if ([fileMgr removeItemAtPath:filePath error:&error] != YES)
        {   UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:NSLocalizedString(@"UnableToDeleteFile", @"Unable to delete file: %@"),[error localizedDescription]] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease];
            [alert show];
        }
        [self.pdfArray removeObjectAtIndex:indexPath.row];

        [self refreshTable];

        [tableView endUpdates];

    }
    [self.tableView reloadData];
}

Where [self refreshTable] shows a view with a label stating that there are no PDF saved:

- (void) refreshTable {
    [self fillArray];
    [self.tableView reloadData];

    if (self.pdfArray.count == 0)
    {
        [UIView animateWithDuration:1.0f animations:^{
            noPDF.view.alpha = 1;
        }];
        self.navigationItem.rightBarButtonItem = nil;
        self.tableView.userInteractionEnabled = NO;
    }
    else
    {
        noPDF.view.alpha = 0;
        self.navigationItem.rightBarButtonItem = self.editButtonItem;
        self.tableView.userInteractionEnabled = YES;
    }

}

Now, I can’t actually get how can I solve this, so, any help highly 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-06-18T04:24:15+00:00Added an answer on June 18, 2026 at 4:24 am

    Wow, perfect timing.
    Soon after i wrote this answer, I made some adjustments to the method [self refreshTable],moving the [self fillArray] method to viewDidLoad and [self refreshTable] to viewDidAppear
    So now I have

    -(void)viewDidLoad{
        [self fillArray];
    }
    
    -(void)viewDidAppear:(BOOL)animated{
       [self refreshTable];
    

    }

    And the row deletion works perfectly.

    Thanks for your time, though.

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

Sidebar

Related Questions

I have a UITableView which shows some information. The informations are from a XMLFile.
I have a UITableView which I want to populate with details from an array
I have an UITableView which includes a list of UITableViewCells. And I set the
I have a UITableView with 3 empty rows. The user can select which text
I have a UITableViewController that shows a list of items from NSMutableArray, along with
I have implemented a UITableView, which shows up fine as a subview in my
I have a UITableView which contains names in each row alongwith images for each
I have a UITableView which is configured to allow rows to be moved between
I have a UITableView which displays about 5 cells at a time, yet in
I have a UITableView which is backed by a NSFetchedResultsController . I would like

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.