IGListKit/Source/Internal/IGListBindingSectionController+DebugDescription.m
Candance Smith 1faf59b302 Added debug dump support to IGListBindingSectionController
Summary:
Issue fixed: #698

- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/856

Differential Revision: D5611625

Pulled By: rnystrom

fbshipit-source-id: d9d54e2a10cf0cfae6cff121c20cc8d24d802716
2017-08-11 09:19:00 -07:00

48 lines
2.4 KiB
Objective-C

/**
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "IGListBindingSectionController+DebugDescription.h"
#import "IGListDebuggingUtilities.h"
@implementation IGListBindingSectionController (DebugDescription)
- (NSString *)debugDescription {
NSMutableArray *lines = [NSMutableArray arrayWithObject:[NSString stringWithFormat:@"IGListBindingSectionController %p:", self]];
[lines addObjectsFromArray:IGListDebugIndentedLines([self debugDescriptionLines])];
return [lines componentsJoinedByString:@"\n"];
}
- (NSArray<NSString *> *)debugDescriptionLines {
NSMutableArray *debug = [NSMutableArray new];
#if IGLK_DEBUG_DESCRIPTION_ENABLED
[debug addObject:[NSString stringWithFormat:@"Data source: %@", self.dataSource]];
[debug addObject:[NSString stringWithFormat:@"Selection delegate: %@", self.selectionDelegate]];
[debug addObject:[NSString stringWithFormat:@"Object: %@", self.object]];
[debug addObject:@"View models:"];
for (id<IGListDiffable> viewModel in self.viewModels) {
[debug addObject:[NSString stringWithFormat:@"%@: %@", viewModel, viewModel.diffIdentifier]];
}
[debug addObject:[NSString stringWithFormat:@"Number of items: %ld", (long)self.numberOfItems]];
[debug addObject:[NSString stringWithFormat:@"View controller: %@", self.viewController]];
[debug addObject:[NSString stringWithFormat:@"Collection context: %@", self.collectionContext]];
[debug addObject:[NSString stringWithFormat:@"Section: %ld", (long)self.section]];
[debug addObject:[NSString stringWithFormat:@"Is first section: %@", IGListDebugBOOL(self.isFirstSection)]];
[debug addObject:[NSString stringWithFormat:@"Is last section: %@", IGListDebugBOOL(self.isLastSection)]];
[debug addObject:[NSString stringWithFormat:@"Supplementary view source: %@", self.supplementaryViewSource]];
[debug addObject:[NSString stringWithFormat:@"Display delegate: %@", self.displayDelegate]];
[debug addObject:[NSString stringWithFormat:@"Working range delegate: %@", self.workingRangeDelegate]];
[debug addObject:[NSString stringWithFormat:@"Scroll delegate: %@", self.scrollDelegate]];
#endif // #if IGLK_DEBUG_DESCRIPTION_ENABLED
return debug;
}
@end