Skip to content

Commit

Permalink
Merge pull request #10 from veronica41/remove_all
Browse files Browse the repository at this point in the history
add dgkvo_removeAllObservers
  • Loading branch information
dannygreg committed Dec 11, 2014
2 parents 0f39551 + d78db65 commit 870039c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions NSObject+DGKVOBlocks.h
Expand Up @@ -32,5 +32,6 @@ typedef void (^DGKVOObserverBlock)(NSDictionary *change);

- (id)dgkvo_addObserverForKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options queue:(NSOperationQueue *)queue usingBlock:(DGKVOObserverBlock)block;
- (void)dgkvo_removeObserverWithIdentifier:(id)identifier;
- (void)dgkvo_removeAllObservers;

@end
10 changes: 10 additions & 0 deletions NSObject+DGKVOBlocks.m
Expand Up @@ -158,4 +158,14 @@ - (void)dgkvo_removeObserverWithIdentifier:(id)identifier
}
}

- (void)dgkvo_removeAllObservers {
[self.dgkvo_blockObservers enumerateObjectsUsingBlock:^(id observer, NSUInteger idx, BOOL *stop) {
[self removeObserver:observer forKeyPath:[observer keyPath]];
}];

@synchronized (self.dgkvo_blockObservers) {
[self.dgkvo_blockObservers removeAllObjects];
}
}

@end

0 comments on commit 870039c

Please sign in to comment.