iCloud Speicher lokal ablegen bzw. lokalen Speicher mit iCloud zusammenführen

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • iCloud Speicher lokal ablegen bzw. lokalen Speicher mit iCloud zusammenführen

    Hallo Entwickler,
    ich habe iCloud in meine App (mit Core Data) integriert und es funktioniert soweit ganz gut. Beim ersten Start der App kann der Nutzer wählen, ob er iCloud nutzen möchte oder nicht. In den Einstellungen habe ich die Möglichkeit hinzugefügt diese Entscheidung zu ändern.

    Wie kann ich am besten den iCloud Speicher lokal ablegen wenn man sich gegen iCloud entscheidet bzw. wie kann ich den bestehenden lokalen Speicher mit der iCloud zusammenführen, wenn der User iCloud wieder nutzen möchte?
  • Dann schaue dir mal das WWDC Video von 2013 zur iCloud in iOS 7 an. Die haben vieles vereinfacht und die Lokale zu Online Migration und Zurück geht jetzt ohne Probleme. Ich habe den Apple-Support auch mal angeschrieben, um meinen iCloud Container von einen alten zu Einen neuen zu Migrieren. Diese Schritte kannst du leicht abgewandelt übernehmen:
    ​... But please note that Core Data iCloud integration changed a lot in iOS 7. The store file is now required to reside in sandbox, rather than a .nosync folder in the ubiquity container. And you need to follow the pattern and practice introduced by Core Data engineering team in “What’s New in Core Data and iCloud” session in WWDC 2013 <developer.apple.com/videos/wwdc/2013/>.

    If you have a new version focusing on iOS 7 (and later), my practice is to:

    1. Use a different NSPersistentStoreUbiquitousContentNameKey value to set up the Core Data stack. With this, the new version will use a different folder for Core Data transaction logs in ubiquity containers, while all the previous version data will still be there.

    2. Migrate the iCloud store data of previous version to a local store, then migrate the local store to the new version iCloud store. You can use NSPersistentStoreCoordinator’s migratePersistentStore… method to do that. After the migration, the data won’t be lost, and the devices with new version sync with each other, the devices with old versions work as before, and devices with different versions won’t sync because they have different NSPersistentStoreUbiquitousContentNameKey value.

    3. In iCloud envrionment, if there are more than one device doing step 2, you will have to design an algorithm to de-duplicate the data.