diff --git a/Source/IGListBindingSectionController.h b/Source/IGListBindingSectionController.h index 482fe348..f66ccc85 100644 --- a/Source/IGListBindingSectionController.h +++ b/Source/IGListBindingSectionController.h @@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN Only when `-diffIdentifier`s match is object equality compared, so you can assume the class is the same, and the instance has already been checked. */ -@interface IGListBindingSectionController : IGListSectionController +@interface IGListBindingSectionController<__covariant ObjectType : id> : IGListSectionController /** A data source that transforms a top-level object into view models, and returns cells and sizes for given view models. @@ -59,6 +59,11 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, weak, nullable) id selectionDelegate; +/** + The object currently assigned to the section controller, if any. + */ +@property (nonatomic, strong, readonly, nullable) ObjectType object; + /** The array of view models created from the data source. Values are changed when the top-level object changes or by calling `-updateAnimated:completion:` manually. diff --git a/Source/IGListBindingSectionController.m b/Source/IGListBindingSectionController.m index 5dffe5a2..ce1617fd 100644 --- a/Source/IGListBindingSectionController.m +++ b/Source/IGListBindingSectionController.m @@ -54,7 +54,11 @@ typedef NS_ENUM(NSInteger, IGListDiffingSectionState) { } oldViewModels = self.viewModels; - self.viewModels = [self.dataSource sectionController:self viewModelsForObject:self.object]; + + id object = self.object; + IGAssert(object != nil, @"Expected IGListBindingSectionController object to be non-nil before updating."); + + self.viewModels = [self.dataSource sectionController:self viewModelsForObject:object]; result = IGListDiff(oldViewModels, self.viewModels, IGListDiffEquality); [result.updates enumerateIndexesUsingBlock:^(NSUInteger oldUpdatedIndex, BOOL *stop) {