1

I have this code:

NSError *error; // NSMigrationManager hates it if you don't provide an error pointer
BOOL result = [manager migrateStoreFromURL:sStoreURL
                                      type:NSSQLiteStoreType
                                   options:nil
                          withMappingModel:mappingModel
                          toDestinationURL:dStoreURL
                           destinationType:NSBinaryStoreType
                        destinationOptions:nil
                                     error:&error];

To my surprise, it's sometimes returning NO and leaving/setting the error pointer to nil. What can cause this?

4

1 回答 1

2

This is caused if you have a custom migration policy that returns NO without setting the error pointer. e.g.

- (BOOL)createDestinationInstancesForSourceInstance:(NSManagedObject *)sInstance entityMapping:(NSEntityMapping *)mapping manager:(SVMigrationManager *)manager error:(NSError **)error;
{
    return NO;
}

Check the code carefully to find any situations where this could occur.

于 2011-03-04T11:34:20.780 回答