I am displaying an array objects in a UITableView with inserts, updated and deletes and occasionally I get the exception below even though I am carefully handling the changes. I have the full code example on GitHub.
https://github.com/brennanMKE/TableMaddness
This sample project uses objects which implement NSCoding and NSCopying as well as isEqual so that updating the table with inserts, updates and deletes can simulate what I am doing in a real app which is having the same problem. I am avoiding using Core Data which would use NSFetchedResultsController so I'd like know if there is something I should use if I am not using Core Data.
Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2903.23/UITableView.m:1330
2013-11-25 14:43:20.217 TableMaddness[13411:70b] 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 (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
Below is the related code.
// determine items which need to be inserted, updated or removed
NSMutableArray *inserts = [#[] mutableCopy];
NSMutableArray *deletes = [#[] mutableCopy];
NSMutableArray *reloads = [#[] mutableCopy];
// look for inserts
for (NSUInteger row=0; row<fetchedItems.count; row++) {
SSTItem *item = fetchedItems[row];
if (![self.currentItems containsObject:item]) {
// inserts are items which are not already in self.items
[inserts addObject:[NSIndexPath indexPathForRow:row inSection:0]];
}
else {
NSUInteger otherIndex = [self.currentItems indexOfObject:item];
SSTItem *otherItem = [self.currentItems objectAtIndex:otherIndex];
if (![item.modified isEqualToDate:otherItem.modified]) {
[reloads addObject:[NSIndexPath indexPathForRow:row inSection:0]];
}
}
}
// look for deletes
for (NSUInteger row=0; row<self.currentItems.count; row++) {
SSTItem *item = self.currentItems[row];
if (![fetchedItems containsObject:item]) {
[deletes addObject:[NSIndexPath indexPathForRow:row inSection:0]];
}
}
static NSString *lock = #"LOCK";
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (kDelay / 4) * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
// lock is required to prevent inconsistencies when changing view orientation during rotation
#synchronized(lock) {
self.currentItems = fetchedItems;
NSUInteger numberOfRowsInSection = [self tableView:self.tableView numberOfRowsInSection:0];
DebugLog(#"numberOfRowsInSection: %li", numberOfRowsInSection);
DebugLog(#"self.items: %li", self.currentItems.count);
MAAssert(self.currentItems.count == numberOfRowsInSection, #"Match is required");
if (inserts.count || deletes.count || reloads.count) {
[self.tableView beginUpdates];
#ifndef NDEBUG
for (NSIndexPath *indexPath in inserts) {
DebugLog(#"Inserting at %li", (long)indexPath.row);
}
for (NSIndexPath *indexPath in deletes) {
DebugLog(#"Deleting at %li", (long)indexPath.row);
}
for (NSIndexPath *indexPath in reloads) {
DebugLog(#"Reloading at %li", (long)indexPath.row);
}
#endif
[self.tableView insertRowsAtIndexPaths:inserts withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView deleteRowsAtIndexPaths:deletes withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView reloadRowsAtIndexPaths:reloads withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
}
}
index++;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, kDelay * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self runNextUpdate];
});
});
- (void)runNextUpdate {
if (index >= self.dataSets.count) {
index = 0;
[self runNextUpdate]; // remove this line
return; // or add this line.
}
Because if this condition is true, your code will run twice almost at the same time, but the data source has not been updated.
Related
I am working on a project using Microsoft Azure services. In that while deleting a row I am getting this error:
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).
Code for table load and delete row is as :
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//medicine list
if (section == 0) {
NSArray *sectionInfo = [self.fetchedResultsController1 fetchedObjects];
return [sectionInfo count];
}
//allergy list
else if (section == 1) {
NSArray *sectionInfo = [self.fetchedResultsController2 fetchedObjects];
return [sectionInfo count];
}
//notes list
else if (section == 2){
NSArray *sectionInfo = [self.fetchedResultsController3 fetchedObjects];
return [sectionInfo count];
}
else
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = #"mcell";
MedicationTableViewCell *cell = (MedicationTableViewCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
// Add utility buttons
NSMutableArray *rightUtilityButtons = [NSMutableArray new];
[rightUtilityButtons sw_addUtilityButtonWithColor: [UIColor colorWithRed:1.0f green:0.231f blue:0.188 alpha:1.0f] title:#"Delete"];
switch (indexPath.section) {
case 0: {
NSManagedObject *item = [self.fetchedResultsController1 objectAtIndexPath:indexPath];
cell.textLabel.text = [item valueForKey:#"name"];
break;
}
case 1: {
NSManagedObject *item = [self.fetchedResultsController2 objectAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:0]];
cell.textLabel.text = [item valueForKey:#"name"];
break;
}
case 2: {
NSManagedObject *item = [self.fetchedResultsController3 objectAtIndexPath: [NSIndexPath indexPathForRow:indexPath.row inSection:0]];
cell.textLabel.text = [item valueForKey:#"title"];
break;
}
default:
break;
}
cell.rightUtilityButtons = rightUtilityButtons;
cell.delegate = self;
return cell;
}
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index {
// Delete button is pressed
NSIndexPath *cellIndexPath = [self.medicationsTableView indexPathForCell:cell];
//fetchingg data from local store first
NSManagedObject *item = [self.fetchedResultsController1 objectAtIndexPath:[NSIndexPath indexPathForRow:cellIndexPath.row inSection:0]];
NSMutableArray *keys = [[NSMutableArray alloc] initWithObjects:#"id", #"name", #"userId", nil];
NSMutableArray *values = [[NSMutableArray alloc] initWithObjects: [item valueForKey:#"id"], [item valueForKey:#"name"], [item valueForKey:#"userId"], nil];
//creating dictionary of data
NSDictionary *dict = [[NSDictionary alloc] initWithObjects:values forKeys:keys];
//calling delete fucntion
[self.authService deleteItem:self.syncTable withDict:dict completion:^{
//removing row from table view
[self.medicationsTableView reloadData];
[self.medicationsTableView deleteRowsAtIndexPaths:#[cellIndexPath] withRowAnimation:UITableViewRowAnimationRight];
}];
break;
}
Please tell where I am going wrong. Thanks in advcance!!!!
In - (void)swipeableTableViewCell: didTriggerRightUtilityButtonWithIndex:
You need to remove either
[self.medicationsTableView reloadData];
or
[self.medicationsTableView deleteRowsAtIndexPaths:#[cellIndexPath] withRowAnimation:UITableViewRowAnimationRight];
Because on first line when reloadData get called it's reload the tableview with new datasource and again calling deleteRowsAtIndexPaths tried to delete a rows which already removed by calling reloadData earlier.
The important thing is that you need to use either
[self.medicationsTableView reloadData];
or
[self.medicationsTableView deleteRowsAtIndexPaths:#[cellIndexPath] withRowAnimation:UITableViewRowAnimationRight];
The reason being, when the tableview's reload data is called the row which is removed from data source is deleted and after that when the delete row api is called for the same index path(where the row is already deleted causes the issue)
Also just before deleting the row from the table delete the object from the data source (self.fetchedResultsController1) and call
[self.medicationsTableView deleteRowsAtIndexPaths:#[cellIndexPath] withRowAnimation:UITableViewRowAnimationRight];
and after the above row's deletion animation is completed than you can call(but it is not required)
[self.medicationsTableView reloadData];
I'm working with a UICollection view and would like to animate changes to it's datasource. New datasource shares a lot of items with the old one, and I would like to animate insertion of new items and deletion of items that are no longer in the datasource, while keeping all other cells intact:
Current: [1,2,8,9]
Updated: [1,2,3,9]
Changes: insert 3, delete 8
Are there examples of swapping datasources for UICollectionView with animation?
I tried this, which causes the collection view to flash, but no animations are being played:
[self.collectionView performBatchUpdates:^{
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
} completion:^(BOOL finished) {
}];
This method complains about numbers of items not matching:
-(void)setDatasource:(NSMutableArray *)datasource
{
NSMutableArray* _datasourceBackup = _datasource;
//find out what is being added and deleted
NSMutableArray* itemsToDelete = [NSMutableArray arrayWithArray:_datasource];
DLog(#"delete raw: %lu", (unsigned long)itemsToDelete.count);
[itemsToDelete removeObjectsInArray:datasource];
DLog(#"delete filtered: %lu", (unsigned long)itemsToDelete.count);
NSMutableArray* itemsToAdd = [NSMutableArray arrayWithArray:datasource];
DLog(#"add raw: %lu", (unsigned long)itemsToAdd.count);
[itemsToAdd removeObjectsInArray:_datasource];
DLog(#"add filtered: %lu", (unsigned long)itemsToAdd.count);
//1 update datasource
_datasource = datasource;
if(_datasourceBackup.count == 0)
{
//original load
[self.collectionView reloadData];
}else
{
[self.collectionView performBatchUpdates:^{
//convert items to add/delete into index paths and give them to collection view to animate
NSMutableArray* indexPathsToDelete = [NSMutableArray array];
for(NSString* identifier in itemsToDelete)
{
NSInteger index = [_datasourceBackup indexOfObject:identifier];
[indexPathsToDelete addObject: [NSIndexPath indexPathForRow:index inSection:0]];
}
if(indexPathsToDelete.count > 0 )
{
[self.collectionView deleteItemsAtIndexPaths:indexPathsToDelete];
}
NSMutableArray* indexPathsToInsert = [NSMutableArray arrayWithCapacity:itemsToAdd.count];
for(NSString* identifier in itemsToAdd)
{
NSInteger index = [_datasource indexOfObject:identifier];
[indexPathsToInsert addObject: [NSIndexPath indexPathForRow:index inSection:0]];
}
if(indexPathsToInsert.count > 0 )
{
[self.collectionView insertItemsAtIndexPaths:indexPathsToInsert];
}
} completion:nil];
}
}
I have an issue where I have a UITableViewController and when the view appears I do some calculations asynchronously which should result in the updating of specific rows in the table.
Inside the viewWillAppear function I calculate the necessary rows that need to be updated as follows:
- (void)reloadPaths:(NSMutableDictionary *)bookingsDict
{
NSMutableArray* indexArray = [NSMutableArray array];
int i = 0;
for (NSString *dateKey in self.eventsToShow) {
NSMutableDictionary *venues = [bookingsDict objectForKey:dateKey];
if (venues) {
int j = 0;
NSArray *events = [self.eventsToShow objectForKey:dateKey];
for (DCTEvent *event in events) {
NSString *venueIdString = [NSString stringWithFormat:#"%#", event.eventVenueId];
if ([venues objectForKey:venueIdString]) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
[indexArray addObject:indexPath];
}
j++;
}
}
i++;
}
[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];
}
However I notice that the cellForRowAtIndexPath function is never called after and the cells do not get updated correctly. Any idea what the issue might be?
EDIT: I just noticed that if I scroll out of the view of the cell that is supposed to get updated then it gets updated when I scroll back into view. Is there no way to have it update while in view?
How about wrap it?
[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates];
Here are some similar problems I have found.
cellForRowAtIndexPath isn't called after reloadRowsAtIndexPaths
UITableView's reloadRowsAtIndexPaths: (NSArray *) indexPaths failing to cause a reload unless you call it twice?
Hope this helps.
EDIT : I think you are not getting indexPath check section might be constant as you are increasing while each object gets traversed:
- (void)reloadPaths:(NSMutableDictionary *)bookingsDict
{
NSMutableArray* indexArray = [NSMutableArray array];
int i = 0;
for (NSString *dateKey in self.eventsToShow) {
NSMutableDictionary *venues = [bookingsDict objectForKey:dateKey];
if (venues) {
int j = 0;
NSArray *events = [self.eventsToShow objectForKey:dateKey];
for (DCTEvent *event in events) {
NSString *venueIdString = [NSString stringWithFormat:#"%#", event.eventVenueId];
if ([venues objectForKey:venueIdString]) {
//changed here as section might be constant as i think it might be
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:0];
[indexArray addObject:indexPath];
}
j++;
}
}
i++;
}
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
}
Try this :
//your code here
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
For me pushing my reload code to the main queue solved the problem
DispatchQueue.main.async {
self.tableView.reloadRows(at: [indexPath], with: .automatic)
}
This question already has answers here:
'Invalid update: invalid number of rows in section 0
(4 answers)
Closed 8 years ago.
i have a problem like this :
i am loading some data to a table view after select a date from a date picker.the data which i want to load is loaded to a variable inside the didSelectRowAtIndexPath method. when the table is checking for the number of rows it checks the count of that variable is grater than zero and so on..
my problem is this : when i load the data to the variable by calling a web service [using AFNetworking library] it is works nicely. but when i get the data directly [i have implemented a method to call web service before the table load, and holds the data] by a method it is giving this error
Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2903.23/UITableView.m:1330
2014-05-02 17:25:12.665 varrdle_v2[1428:a0b] * 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 (3) 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).
* First throw call stack:
i cant figure out why that happens. the only different is the way i taken the data.
below is my implementation
number of rows
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray* reqFdate= [TableViewController getrequestPerDate];
NSLog(#"Count OF REQUESTS: %d",reqFdate.count);
if (reqFdate.count == 0 ) {
NSInteger numberOfRows = [self.persons count];
if ([self datePickerIsShown]){
numberOfRows++;
}
NSLog(#"NO OF ROWS in IF %d",numberOfRows);
return numberOfRows;
}
else{
NSLog(#"NO OF ROWS %d",reqFdate.count);
return reqFdate.count;
}
}
cell for row at indexpath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
NSDate *today = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// display in 12HR/24HR (i.e. 11:25PM or 23:25) format according to User Settings
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *currentTime = [dateFormatter stringFromDate:today];
NSDate *date=[dateFormatter dateFromString:currentTime];
if(indexPath.row==0){
VCPerson *person = self.persons[0];
cell = [self createPersonCell:person];
}
else if ([self datePickerIsShown] && (self.datePickerIndexPath.row == 1)){
// VCPerson *person = self.persons[indexPath.row -1];
cell = [self createPickerCell:date];
}
else{
TacleCell *cell = (TacleCell*)[self.tableView dequeueReusableCellWithIdentifier:otherCellID];
cell.delegate = self;
if(cell == nil)
{
cell = [[TacleCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:otherCellID];
}
else
{
//cancel loading previous image for cell
[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:cell.profileImage];
}
return cell;
}
return cell;
}
didSelect method
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.tableView beginUpdates];
int countOfRowss = [TableViewController getrequestPerDate].count;
if(countOfRowss>0)
{
NSArray* indexpathsArry = [self getIndexPaths];
[self.tableView deleteRowsAtIndexPaths:indexpathsArry withRowAnimation:YES];
requestForDate = nil;
}
if ([self datePickerIsShown] && (self.datePickerIndexPath.row - 1 == indexPath.row)){
[self hideExistingPicker];
//[self.tableView reloadData];
//[self viewDidLoad];
//call the service and take the results
NSString* selecteDate = [TableViewController getDate];
//NSString* prsonID =[LoginView getPersonID];
// here i call this method and get the data.
requestForDate= [self filterRequestForDate:selecteDate];
NSLog(#"FILTERED REQUESTS :%#",requestForDate);
//requestForDate = nil;
[self.tableView reloadData];
// NSString* selecteDate = [ScheduleView getDate];
// this is how i fetch the data by using a web service
/* NSString* prsonID =[LoginView getPersonID];
NSDictionary* parms = [NSDictionary dictionaryWithObjectsAndKeys:prsonID,#"caregiverPersonId",selecteDate,#"selectedDate", nil];
jsonpaser* jp = [[jsonpaser alloc]init];
//[self.indicator_process startAnimating];
[jp getWebServiceResponce:#"myUrl" :parms success:^(NSDictionary *responseObject)
{
requestForDate = responseObject;
NSLog(#"RESPONSEFORDATE_IN DIDSELECT :%#",requestForDate);
NSArray* indexpaths = [self getIndexPaths];
NSLog(#"indexPATHS %#",indexpaths);
//[self.indicator_process stopAnimating];
//[_dimmingView removeFromSuperview];
[self.tableView reloadData];
}];
*/
}
else{
//--
NSIndexPath *newPickerIndexPath = [self calculateIndexPathForNewPicker:indexPath];
if ([self datePickerIsShown]){
[self hideExistingPicker];
}
[self showNewPickerAtIndex:newPickerIndexPath];
self.datePickerIndexPath = [NSIndexPath indexPathForRow:newPickerIndexPath.row + 1 inSection:0];
NSLog(#"DATEPICKERINDEX %#",self.datePickerIndexPath);
//self.datePickerIndexPath = nil;
}
// this is the line where a row deleted
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
[self.tableView endUpdates];
}
please someone tell me where is the issue...
thank you
Regarding to apple documentation apple link you should not call reloadData between beginUpdates and endUpdates.
You should remove the beginUpdates and endUpdates or move the reloadData outside the group.
- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if(editingStyle == UITableViewCellEditingStyleDelete) {
//Get the object to delete from the array.
NSLog(#"%#",[[_arrayForTable valueForKey:#"IDS"] objectAtIndex:[indexPath row]] );
NSInteger myInteger = [[[_arrayForTable valueForKey:#"IDS"] objectAtIndex:[indexPath row]] integerValue];
NSNumber *selRow = [NSNumber numberWithInt:myInteger];
NSLog(#"%#",selRow);
[self removeCell:selRow]; // this is working perfectly it gets remove from database
//Delete the object from the table.
// app get crash here crash report is pested below
[self.table deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
- (void) removeCell:(NSNumber *)selRow{
NSLog(#"_arrayForTable%#",_arrayForTable);
NSInteger myInteger = [selRow integerValue];
[_arrayForTable removeObjectAtIndex:myInteger];
NSLog(#"_arrayForTable%#",_arrayForTable);
if(deleteStmt == nil) {
const char *sql = "delete from PersonNamesAndBirthDates where ID = ?";
NSLog(#"%s",sql);
if(sqlite3_prepare_v2(database1, sql, -1, &deleteStmt, NULL) != SQLITE_OK)
NSAssert1(0, #"Error while creating delete statement. '%s'", sqlite3_errmsg(database1));
}
NSLog(#"%d",myInteger);
//When binding parameters, index starts from 1 and not zero.
sqlite3_bind_int(deleteStmt, 1, myInteger );
if (SQLITE_DONE != sqlite3_step(deleteStmt))
NSAssert1(0, #"Error while deleting. '%s'", sqlite3_errmsg(database1));
sqlite3_reset(deleteStmt);
}
* Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:1046 2013-04-08
17:01:13.069 birthdate reminder 2[583:15803] * 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 (12) must be
equal to the number of rows contained in that section before the
update (12), 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).'
please suggest something
my numberofrow method is below
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return _arrayForTable.count;
}
app is not crashing everytime sometime works sometime crash
Ok, so as I see it, you are getting the ID of a specific row with:
NSInteger myInteger =
[[[_arrayForTable valueForKey:#"IDS"] objectAtIndex:[indexPath row]] integerValue];
NSNumber *selRow = [NSNumber numberWithInt:myInteger];
And then, you're using the ID of that specific row, as the index to remove it from the array.
NSInteger myInteger = [selRow integerValue];
[_arrayForTable removeObjectAtIndex:myInteger];
That's where things go wrong. If the array has the same order as your TableView, you need to remove indexPath.row from it. The ID is necessary for your database.
Try this:
- (void)tableView:(UITableView *)tv commitEditingStyle :(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if(editingStyle == UITableViewCellEditingStyleDelete) {
//Get the object to delete from the array.
NSLog(#"%#",[[_arrayForTable valueForKey:#"IDS"] objectAtIndex:[indexPath row]] );
NSInteger myInteger = [[[_arrayForTable valueForKey:#"IDS"] objectAtIndex:[indexPath row]] integerValue];
NSNumber *selRow = [NSNumber numberWithInt:myInteger];
NSLog(#"%#",selRow);
[self.table beginUpdates];
[self removeCell:selRow]; // this is working perfectly it gets remove from database
//Delete the object from the table.
// app get crash here crash report is pested below
[self.table deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.table endUpdates];
}
}
Notice the [self.table beginUpdates]; and [self.table endUpdates]; around the lines of code which alter the tableview.
IT"S WORKING
at and of your commitEditingStyle method add this line
[TableViewForFirstView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];