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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:04:36+00:00 2026-05-25T21:04:36+00:00

My table view is populated from an array containing data in the core data,

  • 0

My table view is populated from an array containing data in the core data, I want to delete rows while updating the core data correspondingly, here is my code of deletion.

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source.
        NSManagedObject *selectedObject = [arrayList objectAtIndex:[indexPath row]];
        [managedObjectContext deleteObject:selectedObject];

        [arrayList removeObjectAtIndex:[indexPath row]];

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

However, I am getting the following error when I hit delete button:

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:995
*** 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 (4) must be equal to the number of rows contained in that section before the update (4), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).'

My data source is arrayList containing NSManagedObjects fetched from core data.

Ideas? Thanks in advance!


Update:

Now the deletion can work after I remove the data in the arrayList, but data in core data didn’t get deleted correspondingly, when app relaunches, the list is still the same.

  • 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-25T21:04:36+00:00Added an answer on May 25, 2026 at 9:04 pm

    It means that even after you deleted the row, the datasource is still returning 4 as the number of rows in section 0. So now the table view only has 3 rows displayed for a section that should have 4.

    From your description, you probably need to delete the object from arrayList in addition to deleting it from CoreData. Alternatively reload arrayList after deleting the object from CoreData and then delete the row.

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

Sidebar

Related Questions

I have a view which is a big table. This table is populated from
I'm trying to delete a row from my table view and so far have
I want to populate all the data from my database to a table using
I have a table view that i want to populate with information from xml.
I have a Table View Controller with cells. I want to update the text
From the docs: A table view in the UIKit framework is limited to a
I have a UITableView that was created from data coming from a mutable array.
On the Iphone im trying to populate a main table view from a dictionary,
I have a UITableView that is being populated from an NSMutable array that has
I have a table view which i want to populate with the results (XML)

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.