Core Data Migration Very Slow

半世苍凉 提交于 2019-12-23 15:26:05

问题


I'm trying to perform a core data migration and everything is working fine, except that the migration itself takes over 10 seconds. I'm using an xcmappingmodel to map between my two model versions which works fine, except for the length of time it takes.

In the code below, there's a 10 second (or longer!) pause between the "Beginning migration" and "Finished migration" logs. Has anyone encountered such a slow migration before?

I know that all of the data is replicated and transferred to the new store during the migration, but I'm not dealing with a huge dataset, maybe 20 entities with 3,000 records, so I can't imagine it'd take that long.

I'd really appreciate any help - thanks!

Michael

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

NSLog(@"Beginning migration");

if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])
{
    NSLog(@"Auto migration failed, error %@, %@", error, error.userInfo);
    abort();
}   

NSLog(@"Finished migration");

来源:https://stackoverflow.com/questions/10803201/core-data-migration-very-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!