I'm trying to integrate iCloud in my old project but at the same time trying to update the database with MagicalRecord. iCloud works when I'm not using a custom .sqlite file name, but not with a custom one. Here, there is some code that explains better what I mean.
// Load model. Don't use the standard 'merged model' of Magical Record, because that would include
// the Ensembles model. Don't want to merge models.
NSManagedObjectModel *model = [NSManagedObjectModel MR_newManagedObjectModelNamed:@"Polyglott.momd"];
[NSManagedObjectModel MR_setDefaultManagedObjectModel:model];
// Setup Core Data Stack
[MagicalRecord setShouldAutoCreateManagedObjectModel:NO];
// This is the custom file name
[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:@"PolyglottModel"];
// Here is the default one
// [MagicalRecord setupAutoMigratingCoreDataStack];
// Setup Ensemble
// Here, I'm not sure which one is the right way
NSURL *url = [NSPersistentStore MR_urlForStoreName:@"PolyglottModel.sqlite"];
// NSURL *url = [NSPersistentStore MR_urlForStoreName:[MagicalRecord defaultStoreName]];
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Polyglott" withExtension:@"momd"];
self.cloudFileSystem = [[CDEICloudFileSystem alloc] initWithUbiquityContainerIdentifier:@"iCloud.de.thm.polyglott"];
self.ensemble = [[CDEPersistentStoreEnsemble alloc] initWithEnsembleIdentifier:@"PolyglottMR"
persistentStoreURL:url
managedObjectModelURL:modelURL
cloudFileSystem:self.cloudFileSystem];
self.ensemble.delegate = self;
// Listen for local saves, and trigger merges
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(localSaveOccurred:) name:CDEMonitoredManagedObjectContextDidSaveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cloudDataDidDownload:) name:CDEICloudFileSystemDidDownloadFilesNotification object:nil];
[self syncWithCompletion:nil];
leechPersistentStoreWithCompletion nor mergeWithCompletion give me any error but when I request the database, there is no data.
Any idea or example? Thank you so much in advance.