iOS app disable iCloud drive(off) in device settings page and get iCloud persistentStore

| | August 8, 2015

I am developing iOS app with iCloud sync. I stored datas using core data with support of iCloud sync then if i switch off iCloud drive in device settings, My app could not read stored data in UbiquityContainer. Now i want to migrate iCloud persistence store data to local/other place when user iCloud drive is off. But i could not get iCloud persistence store. I tried following methods not working.

NSPersistentStore *result = [self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                               configuration:nil
                                         URL:storeURL
                                     options:options
                                       error:nil];

Result is return nil. Because i could not get exact storeURL of ubiquity store.

 NSURL *iCloudURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:@"iCloud.com.Identifier"];

Gives nil instead of url.Is there a way to get iCloud store after switch off iCloud drive. Because i could not display stored in datas.

Leave a Reply