mirror of
https://github.com/zhigang1992/MagicalRecord.git
synced 2026-01-12 17:32:18 +08:00
include background save queue on cleanup
This commit is contained in:
@@ -21,6 +21,8 @@ typedef enum
|
||||
|
||||
@interface ARCoreDataAction : NSObject {}
|
||||
|
||||
+ (void) cleanUp;
|
||||
|
||||
#ifdef NS_BLOCKS_AVAILABLE
|
||||
|
||||
+ (void) saveDataWithBlock:(void(^)(NSManagedObjectContext *localContext))block;
|
||||
|
||||
@@ -19,8 +19,21 @@ dispatch_queue_t background_save_queue()
|
||||
return coredata_background_save_queue;
|
||||
}
|
||||
|
||||
void cleanup_save_queue()
|
||||
{
|
||||
if (coredata_background_save_queue != NULL)
|
||||
{
|
||||
dispatch_release(coredata_background_save_queue);
|
||||
}
|
||||
}
|
||||
|
||||
@implementation ARCoreDataAction
|
||||
|
||||
+ (void) cleanUp
|
||||
{
|
||||
cleanup_save_queue();
|
||||
}
|
||||
|
||||
#ifdef NS_BLOCKS_AVAILABLE
|
||||
|
||||
+ (void) saveDataWithBlock:(void(^)(NSManagedObjectContext *localContext))block
|
||||
|
||||
@@ -15,9 +15,7 @@ typedef void (^CoreDataBlock)(NSManagedObjectContext *context);
|
||||
|
||||
#endif
|
||||
|
||||
@interface ActiveRecordHelpers : NSObject {
|
||||
|
||||
}
|
||||
@interface ActiveRecordHelpers : NSObject {}
|
||||
|
||||
+ (void) cleanUp;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
#import "ActiveRecordHelpers.h"
|
||||
#import "ARCoreDataAction.h"
|
||||
#import "NSManagedObjectContext+ActiveRecord.h"
|
||||
#import "NSPersistentStoreCoordinator+ActiveRecord.h"
|
||||
#import "NSManagedObjectModel+ActiveRecord.h"
|
||||
@@ -19,6 +20,7 @@ static SEL errorHandlerAction = nil;
|
||||
|
||||
+ (void) cleanUp
|
||||
{
|
||||
[ARCoreDataAction cleanUp];
|
||||
[NSManagedObjectContext setDefaultContext:nil];
|
||||
[NSManagedObjectModel setDefaultManagedObjectModel:nil];
|
||||
[NSPersistentStoreCoordinator setDefaultStoreCoordinator:nil];
|
||||
|
||||
@@ -30,7 +30,8 @@ static NSString const * kActiveRecordManagedObjectContextKey = @"ActiveRecord_NS
|
||||
|
||||
+ (void) setDefaultContext:(NSManagedObjectContext *)moc
|
||||
{
|
||||
if (defaultManageObjectContext != moc) {
|
||||
if (defaultManageObjectContext != moc)
|
||||
{
|
||||
[defaultManageObjectContext release];
|
||||
defaultManageObjectContext = [moc retain];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user