Skip to content

Instantly share code, notes, and snippets.

@pilky
Created October 10, 2012 13:52
Show Gist options
  • Save pilky/3865781 to your computer and use it in GitHub Desktop.
Save pilky/3865781 to your computer and use it in GitHub Desktop.
Test Managed Object Context
//HEADER
typedef NSArray *(^M3TestFetchRequestBlock)(NSFetchRequest *, NSError **);
@interface M3TestManagedObjectContext : NSManagedObjectContext
@property (copy) M3TestFetchRequestBlock fetchRequestBlock;
@end
//IMPLEMENTATION
@implementation M3TestManagedObjectContext
- (NSArray *)executeFetchRequest:(NSFetchRequest *)aRequest error:(NSError *__autoreleasing *)aError {
if (self.fetchRequestBlock) {
return self.fetchRequestBlock(aRequest, aError);
}
return [super executeFetchRequest:aRequest error:aError];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment