Merging with origin/develop

This commit is contained in:
Saul Mora
2012-10-30 09:05:06 -07:00
4 changed files with 5 additions and 41 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,18 +88,7 @@
- (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;

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;