josh
josh

Reputation: 1689

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.

Upvotes: 7

Views: 3300

Answers (2)

Shobhakar Tiwari
Shobhakar Tiwari

Reputation: 7892

[tableView Reload] produces crash then it is pretty sure that there is problem in datasource so i think add breakpoint in tableview section and check whether you are updating your datasource properly otherwise show the complete crash message.

Upvotes: -1

josh
josh

Reputation: 1689

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.

Upvotes: 12

Related Questions