Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App crashing on reloadData method of tableview

My app is crashing after calling method of [tableView reloadData] table view. This is occurring on after deleting a single row of tableview(with table view default deleting behavior) and call [tableView reloadData] and then right after this delegate numberOfSectionsInTableViewapp gets crash and show me crash message [UITableViewCell _setDeleteAnimationInProgress : ] : message sent to deallocated instance, I googled but couldn't able to get healthy response. So kindly help to find out this issue if any one face this sort of crash. Here below is my code.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if(section==0)
        return [[dbSingleton sharedInstance] get_players_count];
    else if(section==1)
        return 0;
}

- (NSString )tableView:(UITableView )tableView titleForHeaderInSection:(NSInteger)section{
    if(section==0)
        return @"Player Detail";
    return nil;
}

- (UITableViewCellEditingStyle)tableView:(UITableView )tableView editingStyleForRowAtIndexPath:(NSIndexPath )indexPath{
    if(indexPath.section==1)
        return UITableViewCellEditingStyleNone;
    else
        return UITableViewCellEditingStyleDelete;
    }
}

-(CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath )indexPath{
    return 44;
}

Looking for response. Thanks in advance.

like image 814
josh Avatar asked Oct 27 '14 13:10

josh


1 Answers

Finally, I found solution. What I was doing wrong is that I am calling method reloadData on commitEditingStyle, its mean reloading data before deleting row, As mention in answer of This Thread. I hope this will help others as well. Thanks for your participations.

like image 200
josh Avatar answered Oct 19 '22 10:10

josh