@@ -161,9 +161,7 @@ - (void)prepareForInsertRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
161161 for (NSString *kind in [self supplementaryKinds ]) {
162162 LOG (@" Populating elements of kind: %@ , for index paths: %@ " , kind, indexPaths);
163163 NSMutableArray <ASIndexedNodeContext *> *contexts = [NSMutableArray array ];
164- for (NSIndexPath *indexPath in indexPaths) {
165- [self _populateSupplementaryNodeOfKind: kind atIndexPath: indexPath mutableContexts: contexts];
166- }
164+ [self _populateSupplementaryNodesOfKind: kind atIndexPaths: indexPaths mutableContexts: contexts];
167165 _pendingContexts[kind] = contexts;
168166 }
169167}
@@ -190,9 +188,7 @@ - (void)prepareForReloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
190188{
191189 for (NSString *kind in [self supplementaryKinds ]) {
192190 NSMutableArray <ASIndexedNodeContext *> *contexts = [NSMutableArray array ];
193- for (NSIndexPath *indexPath in indexPaths) {
194- [self _populateSupplementaryNodeOfKind: kind atIndexPath: indexPath mutableContexts: contexts];
195- }
191+ [self _populateSupplementaryNodesOfKind: kind atIndexPaths: indexPaths mutableContexts: contexts];
196192 _pendingContexts[kind] = contexts;
197193 }
198194}
@@ -245,6 +241,23 @@ - (void)_populateSupplementaryNodesOfKind:(NSString *)kind withSections:(NSIndex
245241 }];
246242}
247243
244+ - (void )_populateSupplementaryNodesOfKind : (NSString *)kind atIndexPaths : (NSArray <NSIndexPath *> *)indexPaths mutableContexts : (NSMutableArray <ASIndexedNodeContext *> *)contexts
245+ {
246+ NSMutableIndexSet *sections = [NSMutableIndexSet indexSet ];
247+ for (NSIndexPath *indexPath in indexPaths) {
248+ [sections addIndex: indexPath.section];
249+ }
250+
251+ [sections enumerateIndexesUsingBlock: ^(NSUInteger idx, BOOL *stop) {
252+ NSUInteger rowNum = [self .collectionDataSource dataController: self supplementaryNodesOfKind: kind inSection: idx];
253+ NSIndexPath *sectionIndex = [[NSIndexPath alloc ] initWithIndex: idx];
254+ for (NSUInteger i = 0 ; i < rowNum; i++) {
255+ NSIndexPath *indexPath = [sectionIndex indexPathByAddingIndex: i];
256+ [self _populateSupplementaryNodeOfKind: kind atIndexPath: indexPath mutableContexts: contexts];
257+ }
258+ }];
259+ }
260+
248261- (void )_populateSupplementaryNodeOfKind : (NSString *)kind atIndexPath : (NSIndexPath *)indexPath mutableContexts : (NSMutableArray <ASIndexedNodeContext *> *)contexts
249262{
250263 ASCellNodeBlock supplementaryCellBlock;
0 commit comments