IGListKit
IGListKit copied to clipboard
How to delete Items in ListBindingSectionController
New issue checklist
- [ ] I have reviewed the
README
and documentation - [ ] I have searched existing issues and this is not a duplicate
- [ ] I have attempted to reproduce the issue and include an example project.
General information
-
IGListKit
version: - iOS version(s):
- CocoaPods/Carthage version:
- Xcode version:
- Devices/Simulators affected:
- Reproducible in the demo project? (Yes/No):
- Related issues:
Debug information
erminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (3) must be equal to the number of items contained in that section before the update (3), plus or minus the number of items inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).
# Please include debug logs using the following lldb command:
po [IGListDebugger dump]
This is my code ,I want to delete this item but crash
func deleteComment(_ comment: CommentListData) {
guard let index = sectionObjects.firstIndex(of: comment) else {
return
}
self.collectionContext?.performBatch(animated: true, updates: { (batchContext) in
self.sectionObjects.remove(at: index)
batchContext.delete(in: self, at: IndexSet(integer: deleteIndex))
}, completion: nil)
}
You can try to use this method to change ListBindingSectionControllerDataSource
/**
Tells the section controller to query for new view models, diff the changes, and update its cells.
@param animated A flag indicating if the transition should be animated or not.
@param completion An optional completion block executed after updates finish. Parameter is YES if updates were applied.
*/
- (void)updateAnimated:(BOOL)animated completion:(nullable void (^)(BOOL updated))completion;