I have a new CoreData OS X Swift application that I just changed over to use SQLite and iCloud instead of a local-only SQLite database. The primary view consists of an NSArrayController using entity bindings to one of the tables. While the application loads just as fast as always, the transition from "Using local storage: 1" to "Using local storage: 0" takes about a solid minute, even when the database doesn't contain any records.
The CoreData code is pretty much stock. Here's the creation of the NSPersistentStoreCoordinator:
coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("CocoaAppCD.storedata")
do {
var opts: [String:AnyObject] = [String:AnyObject]()
opts.updateValue(true, forKey: NSMigratePersistentStoresAutomaticallyOption)
opts.updateValue(true, forKey: NSInferMappingModelAutomaticallyOption)
opts.updateValue(CloudDatabaseContentNameKey, forKey: NSPersistentStoreUbiquitousContentNameKey)
try coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: opts)
} catch {
failError = error as NSError
}
When the application boots I can interact with the NSTableView/NSArrayController as expected and any NSManagedObject records are preserved and merged in with iCloud records as expected when CoreData finishes the transition. No threads seem to be blocking.. it's just excruciatingly slow to get the NSArrayController to populate the view. Here's a filtered log showing an almost 60 second transition time:
2015-09-13 21:43:14.496 DrugBank 4[3822:3259485] -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](874): CoreData: Ubiquity: preston~0A4E2C8E-B579-5648-9BDB-3C7E63032C5F:MyApp
Using local storage: 1 for new NSFileManager current token <dd6e8bec 22c81862 daa5eb01 2539d106 0ad255e1>
2015-09-13 21:44:11.756 DrugBank 4[3822:3259561] -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](874): CoreData: Ubiquity: preston~0A4E2C8E-B579-5648-9BDB-3C7E63032C5F:MyApp
Using local storage: 0 for new NSFileManager current token <dd6e8bec 22c81862 daa5eb01 2539d106 0ad255e1>
Why is this happening? Even when I delete all records and then nuke the local Container, a "fresh" boot still takes about a minute every time.
What's going on?
Aucun commentaire:
Enregistrer un commentaire