Skip to content

Commit

Permalink
Merge pull request #80 from hanief/master
Browse files Browse the repository at this point in the history
Add controllerWillPerformFetch and controllerDidPerformFetch as delegate methods
  • Loading branch information
bigfish24 committed May 2, 2016
2 parents 07a10bf + 3964649 commit 7426d08
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions RBQFetchedResultsController/Source/RBQFetchedResultsController.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@
*/
- (void)controllerDidChangeContent:(nonnull RBQFetchedResultsController *)controller;

/**
* This method is called before the controller performs the fetch.
*
* @param controller controller instance that will perform the fetch
*/
- (void)controllerWillPerformFetch:(nonnull RBQFetchedResultsController *)controller;

/**
* This method is called after the controller successfully fetches objects. It will not be called if the fetchRequest is nil.
*
* @param controller controller instance that performed the fetch
*/
- (void)controllerDidPerformFetch:(nonnull RBQFetchedResultsController *)controller;

@end

#pragma mark - RBQFetchedResultsController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ - (id)initWithFetchRequest:(RBQFetchRequest *)fetchRequest

- (BOOL)performFetch
{
if ([self.delegate respondsToSelector:@selector(controllerWillPerformFetch:)]) {
[self.delegate controllerWillPerformFetch:self];
}

if (self.fetchRequest) {

if (self.cacheName) {
Expand All @@ -398,6 +402,10 @@ - (BOOL)performFetch
// Only register for changes after the cache was created!
[self registerChangeNotifications];

if ([self.delegate respondsToSelector:@selector(controllerDidPerformFetch:)]) {
[self.delegate controllerDidPerformFetch:self];
}

return YES;
}

Expand Down

0 comments on commit 7426d08

Please sign in to comment.