Prevent calling endUpdatesAnimated:completion: in an unbalanced way

This commit is contained in:
Michael Schneider
2016-06-29 11:20:24 -07:00
parent 5d7f3b4293
commit 9be2f1db4e

View File

@@ -18,22 +18,19 @@
#import "ASDataController+Subclasses.h"
@interface ASChangeSetDataController ()
@property (nonatomic, assign) NSUInteger changeSetBatchUpdateCounter;
@property (nonatomic, strong) _ASHierarchyChangeSet *changeSet;
@end
@implementation ASChangeSetDataController
@implementation ASChangeSetDataController {
NSInteger _changeSetBatchUpdateCounter;
_ASHierarchyChangeSet *_changeSet;
}
#pragma mark - Batching (External API)
- (void)beginUpdates
{
ASDisplayNodeAssertMainThread();
if (_changeSetBatchUpdateCounter == 0) {
if (_changeSetBatchUpdateCounter <= 0) {
_changeSet = [_ASHierarchyChangeSet new];
_changeSetBatchUpdateCounter = 0;
}
_changeSetBatchUpdateCounter++;
}
@@ -43,6 +40,9 @@
ASDisplayNodeAssertMainThread();
_changeSetBatchUpdateCounter--;
// Prevent calling endUpdatesAnimated:completion: in an unbalanced way
NSAssert(_changeSetBatchUpdateCounter >= 0, @"endUpdatesAnimated:completion: called without having a balanced beginUpdates call");
if (_changeSetBatchUpdateCounter == 0) {
[_changeSet markCompleted];