removed MR_saveErrorHandler, as it and MR_saveWithErrorCallback were essentially duplicates

MR_save now only saves the current context (it was essentially doing a MR_saveNestedContexts). If you need to save all the way out to disk, use MR_saveNestedContexts.
Removed the action queue, unneccesary since core data introduced it's own queue support
This commit is contained in:
Stephen Vanterpool
2012-10-25 16:18:07 -07:00
parent 64a81c6ff3
commit f7c4350e9d
4 changed files with 5 additions and 43 deletions

View File

@@ -11,7 +11,7 @@
@interface NSManagedObjectContext (MagicalSaves)
- (void) MR_save;
- (void) MR_saveErrorHandler:(void (^)(NSError *))errorCallback;
- (void) MR_saveWithErrorCallback:(void(^)(NSError *))errorCallback;
- (void) MR_saveInBackgroundCompletion:(void (^)(void))completion;
- (void) MR_saveInBackgroundErrorHandler:(void (^)(NSError *))errorCallback;

View File

@@ -88,20 +88,7 @@
- (void) MR_save;
{
[self MR_saveErrorHandler:nil];
}
- (void) MR_saveErrorHandler:(void (^)(NSError *))errorCallback;
{
[self performBlockAndWait:^{
[self MR_saveWithErrorCallback:errorCallback];
if (self.parentContext) {
[[self parentContext] performBlockAndWait:^{
[[self parentContext] MR_saveErrorHandler:errorCallback];
}];
}
}];
[self MR_saveWithErrorCallback:nil];
}
- (void) MR_saveInBackgroundCompletion:(void (^)(void))completion;

View File

@@ -8,38 +8,15 @@
#import "CoreData+MagicalRecord.h"
#import "NSManagedObjectContext+MagicalRecord.h"
static dispatch_queue_t background_action_queue;
dispatch_queue_t action_queue(void);
dispatch_queue_t action_queue(void)
{
if (background_action_queue == NULL)
{
background_action_queue = dispatch_queue_create("com.magicalpanda.magicalrecord.actionQueue", DISPATCH_QUEUE_SERIAL);
}
return background_action_queue;
}
void reset_action_queue(void);
void reset_action_queue(void)
{
if (background_action_queue != NULL)
{
MRDispatchQueueRelease(background_action_queue);
background_action_queue = NULL;
}
}
@implementation MagicalRecord (Actions)
+ (void) saveInBackgroundUsingContext:(NSManagedObjectContext *)localContext block:(void (^)(NSManagedObjectContext *))block completion:(void(^)(void))completion errorHandler:(void(^)(NSError *))errorHandler;
{
dispatch_async(action_queue(), ^{
[localContext performBlock: ^{
block(localContext);
[localContext MR_saveNestedContextsErrorHandler:errorHandler completion:completion];
});
}];
}
+ (void) saveInBackgroundWithBlock:(void (^)(NSManagedObjectContext *))block completion:(void (^)(void))completion errorHandler:(void (^)(NSError *))errorHandler;
@@ -66,7 +43,7 @@ void reset_action_queue(void)
if ([localContext hasChanges])
{
[localContext MR_saveErrorHandler:errorHandler];
[localContext MR_saveWithErrorCallback:errorHandler];
}
if (completion)

View File

@@ -20,7 +20,6 @@
@end
void reset_action_queue(void);
@implementation MagicalRecord
@@ -28,7 +27,6 @@ void reset_action_queue(void);
{
[self cleanUpErrorHanding];
[self cleanUpStack];
reset_action_queue();
}
+ (void) cleanUpStack;