-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Hello there,
I got application crash every time when I try to close the previous section and open a new section.
Crash happened at line tableview.endupdate() in below code ,
fileprivate func sectionHeaderViewOpenedAtIndex(_ index: Int) {
let section = sections[index]
section.open = true
var indexPathsToInsert = [IndexPath]()
var indexPathsToDelete = [IndexPath]()
indexPathsToInsert.append(IndexPath(row: 0, section: index))
if openedSectionIndex != NSNotFound {
let previousOpenSection = sections[openedSectionIndex]
let praviousSectionHeaderView = tableView.headerView(forSection: openedSectionIndex) as! SectionHeaderView
praviousSectionHeaderView.disclosureButton.isSelected = false
previousOpenSection.open = false
indexPathsToDelete.append(IndexPath(row: 0, section: openedSectionIndex))
delegate?.accordionTableViewControllerSectionDidClose(previousOpenSection)
}
tableView.beginUpdates()
tableView.insertRows(at: indexPathsToInsert, with: openAnimation)
tableView.deleteRows(at: indexPathsToDelete, with: closeAnimation)
tableView.endUpdates()
let sectionRect = tableView.rect(forSection: index)
tableView.scrollRectToVisible(sectionRect, animated: true)
openedSectionIndex = index
delegate?.accordionTableViewControllerSectionDidOpen(section)
}
error : Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 0 from section 1 which only contains 0 rows before the update'
Please let me know if there is any update in the library or if I miss something in above logic.
Any help will be appreciated :)
Metadata
Metadata
Assignees
Labels
No labels