Migrate Persistant Store Crash
У меня есть переключатель, который включает или выключает iCloud для приложения iOS 7. Синхронизация iCloud работает отлично. Когда iCloud включен и я его выключаю, я вызываю этот код:
- (void)migrateiCloudStoreToLocalStore {
NSError *error;
__weak NSPersistentStoreCoordinator *psc = self.managedObjectContext.persistentStoreCoordinator;
NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption:@YES,
NSPersistentStoreRemoveUbiquitousMetadataOption : @YES};
NSPersistentStore *currentStore = [psc persistentStores][0];
NSLog(@"iCloud Store - %@", currentStore);
NSLog(@"Local Store - %@", self.store);
[psc migratePersistentStore:currentStore
toURL:self.store
options:options
withType:NSSQLiteStoreType
error:&error];
}
Я вижу, что оба магазина существуют, но все равно происходит сбой, когдаmigratePersistentStore:toURL:options:withType:error:
называется.
Вот ошибка, которую я получаю:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM replaceObjectAtIndex:withObject:]: object cannot be nil' *** First throw call stack: (0x2e0a3fd3 0x38850ccf 0x2dfdf29f 0x2de9e7f7 0xa9b61 0xb2305 0xb019f 0x309de05f 0x30a90377 0x3093f6f5 0x308b855b 0x2e06f2a5 0x2e06cc49 0x2e06cf8b 0x2dfd7f4f 0x2dfd7d33 0x32edc663 0x3092316d 0x30289 0x38d5dab7) libc++abi.dylib: terminating with uncaught exception of type NSException
Есть идеи, почему это происходит? Это немного странно, потому что на одном из моих других устройств в этот момент не происходит сбой.