Table View Reload Sections Crashes

I had the same issue in UITableViewCell comprising UISwitch. I solved the problem by calling [self.tableview reloadData] before reloading the sections:

NSIndexSet *sections = [[NSIndexSet alloc] initWithIndex:2];
[self.tableView reloadData];
[self.tableView reloadSections:sections withRowAnimation:UITableViewRowAnimationFade];

The same problem happens if you call:

[self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationFade]

without reloading the data first.


you haven't added a crash log but im guessing you are getting an error that states an existing number of rows in a section must be equal to some value before an update. If that's the case, Did you use [self.tableview beginUpdates] before reloading the table and [self.tableview endUpdates] after reloading?