Merge pull request #918 from levi/master

Inline supplementary kind iteration in data controller
This commit is contained in:
appleguy 2015-12-07 12:58:25 -08:00
commit c9a0a3d46f

View File

@ -40,8 +40,7 @@
- (void)prepareForReloadData - (void)prepareForReloadData
{ {
NSArray *kinds = [self supplementaryKinds]; for (NSString *kind in [self supplementaryKinds]) {
for (NSString *kind in kinds) {
LOG(@"Populating elements of kind: %@", kind); LOG(@"Populating elements of kind: %@", kind);
NSMutableArray *indexPaths = [NSMutableArray array]; NSMutableArray *indexPaths = [NSMutableArray array];
NSMutableArray *nodes = [NSMutableArray array]; NSMutableArray *nodes = [NSMutableArray array];
@ -83,8 +82,7 @@
- (void)prepareForInsertSections:(NSIndexSet *)sections - (void)prepareForInsertSections:(NSIndexSet *)sections
{ {
NSArray *kinds = [self supplementaryKinds]; for (NSString *kind in [self supplementaryKinds]) {
for (NSString *kind in kinds) {
LOG(@"Populating elements of kind: %@, for sections: %@", kind, sections); LOG(@"Populating elements of kind: %@, for sections: %@", kind, sections);
NSMutableArray *nodes = [NSMutableArray array]; NSMutableArray *nodes = [NSMutableArray array];
NSMutableArray *indexPaths = [NSMutableArray array]; NSMutableArray *indexPaths = [NSMutableArray array];
@ -116,8 +114,7 @@
- (void)willDeleteSections:(NSIndexSet *)sections - (void)willDeleteSections:(NSIndexSet *)sections
{ {
NSArray *kinds = [self supplementaryKinds]; for (NSString *kind in [self supplementaryKinds]) {
for (NSString *kind in kinds) {
NSArray *indexPaths = ASIndexPathsForMultidimensionalArrayAtIndexSet([self editingNodesOfKind:kind], sections); NSArray *indexPaths = ASIndexPathsForMultidimensionalArrayAtIndexSet([self editingNodesOfKind:kind], sections);
[self deleteNodesOfKind:kind atIndexPaths:indexPaths completion:nil]; [self deleteNodesOfKind:kind atIndexPaths:indexPaths completion:nil];
@ -127,8 +124,7 @@
- (void)prepareForReloadSections:(NSIndexSet *)sections - (void)prepareForReloadSections:(NSIndexSet *)sections
{ {
NSArray *kinds = [self supplementaryKinds]; for (NSString *kind in [self supplementaryKinds]) {
for (NSString *kind in kinds) {
NSMutableArray *nodes = [NSMutableArray array]; NSMutableArray *nodes = [NSMutableArray array];
NSMutableArray *indexPaths = [NSMutableArray array]; NSMutableArray *indexPaths = [NSMutableArray array];
[self _populateSupplementaryNodesOfKind:kind withSections:sections mutableNodes:nodes mutableIndexPaths:indexPaths]; [self _populateSupplementaryNodesOfKind:kind withSections:sections mutableNodes:nodes mutableIndexPaths:indexPaths];
@ -154,8 +150,7 @@
- (void)willMoveSection:(NSInteger)section toSection:(NSInteger)newSection - (void)willMoveSection:(NSInteger)section toSection:(NSInteger)newSection
{ {
NSArray *kinds = [self supplementaryKinds]; for (NSString *kind in [self supplementaryKinds]) {
for (NSString *kind in kinds) {
NSArray *indexPaths = ASIndexPathsForMultidimensionalArrayAtIndexSet([self editingNodesOfKind:kind], [NSIndexSet indexSetWithIndex:section]); NSArray *indexPaths = ASIndexPathsForMultidimensionalArrayAtIndexSet([self editingNodesOfKind:kind], [NSIndexSet indexSetWithIndex:section]);
NSArray *nodes = ASFindElementsInMultidimensionalArrayAtIndexPaths([self editingNodesOfKind:kind], indexPaths); NSArray *nodes = ASFindElementsInMultidimensionalArrayAtIndexPaths([self editingNodesOfKind:kind], indexPaths);
[self deleteNodesOfKind:kind atIndexPaths:indexPaths completion:nil]; [self deleteNodesOfKind:kind atIndexPaths:indexPaths completion:nil];