Permalink
Browse files

Merging with origin/develop

  • Loading branch information...
2 parents 0fb7d36 + f7c4350 commit 0af0731093377295d777c7eda0d09a4d3155600a @casademora casademora committed Oct 30, 2012
@@ -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;
@@ -88,18 +88,7 @@ - (void) MR_saveNestedContextsErrorHandler:(void (^)(NSError *))errorCallback co
- (void) MR_save;
{
- [self MR_saveErrorHandler:nil];
-}
-
-- (void) MR_saveErrorHandler:(void (^)(NSError *))errorCallback;
-{
- [self performBlockAndWait:^{
- [self MR_saveWithErrorCallback:errorCallback];
-
- [[self parentContext] performBlockAndWait:^{
- [[self parentContext] MR_saveErrorHandler:errorCallback];
- }];
- }];
+ [self MR_saveWithErrorCallback:nil];
}
- (void) MR_saveInBackgroundCompletion:(void (^)(void))completion;
@@ -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) saveWithBlock:(void (^)(NSManagedObjectContext *localContext))block com
if ([localContext hasChanges])
{
- [localContext MR_saveErrorHandler:errorHandler];
+ [localContext MR_saveWithErrorCallback:errorHandler];
}
if (completion)
@@ -20,15 +20,13 @@ + (void) MR_cleanUp;
@end
-void reset_action_queue(void);
@implementation MagicalRecord
+ (void) cleanUp
{
[self cleanUpErrorHanding];
[self cleanUpStack];
- reset_action_queue();
}
+ (void) cleanUpStack;

0 comments on commit 0af0731

Please sign in to comment.