Skip to content

Commit

Permalink
Array params have been removed
Browse files Browse the repository at this point in the history
`performSelector:withObject:afterDelay` replaced to `dispatch_after` in
same time
  • Loading branch information
ilin-in committed Feb 21, 2013
1 parent b30bb2b commit 2e986ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern NSString * const kMagicalRecordPSCDidCompleteiCloudSetupNotification;

- (NSPersistentStore *) MR_addInMemoryStore;
- (NSPersistentStore *) MR_addAutoMigratingSqliteStoreNamed:(NSString *) storeFileName;
- (NSPersistentStore *) MR_addAutoMigratingCustomStoreNamed:(NSArray *) params;
- (NSPersistentStore *) MR_addAutoMigratingCustomStoreNamed:(NSString*)fileName storeType:(NSString*)storeTypeName;
- (NSPersistentStore *) MR_addSqliteStoreNamed:(id)storeFileName withOptions:(__autoreleasing NSDictionary *)options;
- (NSPersistentStore *) MR_addCustomStoreNamed:(id)storeFileName withOptions:(__autoreleasing NSDictionary *)options storeType:(NSString*)storeType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,9 @@ - (NSPersistentStore *) MR_addAutoMigratingSqliteStoreNamed:(NSString *) storeFi
return [self MR_addSqliteStoreNamed:storeFileName withOptions:options];
}

/**
@params Array of parameters:
- Store file name
- Store type name
*/
- (NSPersistentStore *) MR_addAutoMigratingCustomStoreNamed:(NSArray *) params;
{
if (params.count < 2) {
MRLog(@"Error: Argument count mismatch on '%s'.", __FUNCTION__);
}
- (NSPersistentStore *) MR_addAutoMigratingCustomStoreNamed:(NSString*)fileName storeType:(NSString*)storeTypeName {
NSDictionary *options = [[self class] MR_autoMigrationOptions];
return [self MR_addCustomStoreNamed:params[0] withOptions:options storeType:params[1]];
return [self MR_addCustomStoreNamed:fileName withOptions:options storeType:storeTypeName];
}

#pragma mark - Public Class Methods
Expand Down Expand Up @@ -188,12 +179,17 @@ + (NSPersistentStoreCoordinator *) MR_coordinatorWithAutoMigratingCustomStoreNam
storeType = NSSQLiteStoreType;
}

[coordinator MR_addAutoMigratingCustomStoreNamed:@[storeFileName, storeType]];
[coordinator MR_addAutoMigratingCustomStoreNamed:storeFileName storeType:storeType];

//HACK: lame solution to fix automigration error "Migration failed after first pass"
if ([[coordinator persistentStores] count] == 0)
if ([[coordinator persistentStores] count] == 0)
{
[coordinator performSelector:@selector(MR_addAutoMigratingCustomStoreNamed:) withObject:@[storeFileName, storeType] afterDelay:0.5];
int64_t delay = 0.5;
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC);
dispatch_after(time, dispatch_get_current_queue(), ^(void){
[coordinator performSelector:@selector(MR_addAutoMigratingSqliteStoreNamed:) withObject:storeFileName afterDelay:0.5];
[coordinator MR_addAutoMigratingCustomStoreNamed:storeFileName storeType:storeType];
});
}

return coordinator;
Expand Down

0 comments on commit 2e986ac

Please sign in to comment.