I'm using a remote database with Core Data and when I execute the following fetch requests, depending on the internet connection, it can take some time. I'd like to monitor these two requests and, when they are complete -- whether successful or failed -- I'd like to trigger another method.
FetchRequest 1:
[self.managedObjectContext executeFetchRequest:fetchRequest1 onSuccess:^(NSArray *results) {
//Succcess
[self.refreshControl endRefreshing];
} onFailure:^(NSError *error) {
[self.refreshControl endRefreshing];
}];
FetchRequest 2:
[self.managedObjectContext executeFetchRequest:fetchRequest2 onSuccess:^(NSArray *results) {
//Succcess
[self.refreshControl endRefreshing];
} onFailure:^(NSError *error) {
[self.refreshControl endRefreshing];
}];
I would like to wait until fetch requests 1 and 2 are both complete before calling another method.
Can I use NSOperationQueue
to monitor both blocks? If not, what's the best way to know when both blocks have completed?