mluisbrown / iCloudCoreDataStack

A persistence stack for using Core Data with iCloud Sync in iOS7
126 stars 11 forks source link

Lightweight Migration / Versioning #7

Closed peterknapp closed 10 years ago

peterknapp commented 10 years ago

Hi, a rather basic question regarding versioning, but before I mess up existing Core Data Models I wanted to ask for your advice.

How do I have to modify your code to change xcdatamodels? Basically, how to add NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption? And are there any other thinks to make sure to do?

Again, sorry for this perhaps rookie level question.

rgds, Peter

mluisbrown commented 10 years ago

Hi Peter, Sorry for taking so long to get back to you. Yes, all you need to do is add the NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption keys (with values of YES) to the options dictionary when adding the persistent store:

[self.managedObjectContext.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                                                   configuration:nil
                                                                             URL:self.storeURL
                                                                         options:@{ NSPersistentStoreUbiquitousContentNameKey : @"iCloudStore",
                                                                                    NSMigratePersistentStoresAutomaticallyOption : @YES,
                                                                                    NSInferMappingModelAutomaticallyOption : @YES }
                                                                           error:&error];

That's pretty much it. No other steps required, all though I would always take a backup and run some tests to see if it's all working as you expect!

You can leave those options in even if you're not migrating models. They won't do any harm. And btw, it's not a rookie question :)

Regards, Michael.

peterknapp commented 10 years ago

Hi Michael,

thank you very much that you find time to answer me. I really appreciate it!

I did not changed the xdatamodel until now so I can not give feedback to this, but:

I just opened my working iOS7 App in Xcode6 bet6 and after putting away one error (concerning auto layout) and some warnings, I get this concerning the iCloud Store File after build and run (short version):

Using local storage: 1

… WAITING SOME MINUTES...

Download failed for file, error: Error Domain=NSCocoaErrorDomain Code=512 "The file download timed out." UserInfo=0x155e08b0 {NSLocalizedDescription=The file download timed out.}

Using local storage: 0

No content appears in my App.

I had to create a new provisioning profile for code signing too. Can you perhaps think of what to do? Is it because of the new provisioning profile?...

I can provide you with the full log text if you want.

Best regards from Berlin, Peter

On 18.08.2014, at 11:46, Michael Brown notifications@github.com wrote:

Hi Peter, Sorry for taking so long to get back to you. Yes, all you need to do is add the NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption keys (with values of YES) to the options dictionary when adding the persistent store:

[self.managedObjectContext.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:self.storeURL options:@{ NSPersistentStoreUbiquitousContentNameKey : @"iCloudStore", NSMigratePersistentStoresAutomaticallyOption : @YES, NSInferMappingModelAutomaticallyOption : @YES } error:&error]; That's pretty much it. No other steps required, all though I would always take a backup and run some tests to see if it's all working as you expect!

Regards, Michael.

— Reply to this email directly or view it on GitHub.

mluisbrown commented 10 years ago

Hi Peter, I haven't tried running any of my apps in Xcode 6 yet, I don't know if I'll have the same problem or not. I suspect this is just an issue with iCloud and Xcode 6 / iOS 8 beta. Sorry I can't help you more.

Regards, Michael.