Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed approach to a notification

  • Loading branch information...
commit bbbf3c307cd7d197b3284dee81b3db377022b41b 1 parent 3f98fc9
@ccwasden ccwasden authored
View
2  MagicalRecord/Categories/NSPersistentStoreCoordinator+MagicalRecord.h
@@ -9,6 +9,8 @@
#import "NSPersistentStore+MagicalRecord.h"
extern NSString * const kMagicalRecordPSCDidCompleteiCloudSetupNotification;
+extern NSString * const kMagicalRecordPSCWillDeleteStoreDueToModelMismatch;
+extern NSString * const kMagicalRecordPSCDidDeleteStoreDueToModelMismatch;
@interface NSPersistentStoreCoordinator (MagicalRecord)
View
6 MagicalRecord/Categories/NSPersistentStoreCoordinator+MagicalRecord.m
@@ -10,6 +10,8 @@
static NSPersistentStoreCoordinator *defaultCoordinator_ = nil;
NSString * const kMagicalRecordPSCDidCompleteiCloudSetupNotification = @"kMagicalRecordPSCDidCompleteiCloudSetupNotification";
+NSString * const kMagicalRecordPSCWillDeleteStoreDueToModelMismatch = @"kMagicalRecordPSCWillDeleteStoreDueToModelMismatch";
+NSString * const kMagicalRecordPSCDidDeleteStoreDueToModelMismatch = @"kMagicalRecordPSCDidDeleteStoreDueToModelMismatch";
@interface NSDictionary (MagicalRecordMerging)
@@ -83,6 +85,7 @@ - (NSPersistentStore *) MR_addSqliteStoreNamed:(id)storeFileName withOptions:(__
BOOL isMigrationError = (([error code] == NSPersistentStoreIncompatibleVersionHashError) || ([error code] == NSMigrationMissingSourceModelError));
if ([[error domain] isEqualToString:NSCocoaErrorDomain] && isMigrationError)
{
+ [[NSNotificationCenter defaultCenter] postNotificationName:kMagicalRecordPSCWillDeleteStoreDueToModelMismatch object:nil];
// Could not open the database, so... kill it! (AND WAL bits)
NSString *rawURL = [url absoluteString];
NSURL *shmSidecar = [NSURL URLWithString:[rawURL stringByAppendingString:@"-shm"]];
@@ -101,13 +104,14 @@ - (NSPersistentStore *) MR_addSqliteStoreNamed:(id)storeFileName withOptions:(__
error:&error];
if (store)
{
+ [[NSNotificationCenter defaultCenter] postNotificationName:kMagicalRecordPSCDidDeleteStoreDueToModelMismatch object:nil];
// If we successfully added a store, remove the error that was initially created
error = nil;
}
}
}
+ [MagicalRecord handleErrors:error];
}
- [MagicalRecord handleErrors:error];
return store;
}
Please sign in to comment.
Something went wrong with that request. Please try again.