问题
I used the sample code from the new CoreData Recipes project (iPhoneCoreDataRecipes Sample Code) to build in iCloud syncing in an existing iOS application which uses a CoreData SQLite "Database" in combination with a very complex data model with lots of many-too-many-relationships (Maybe this is part of the cause of my problem or at least a hint).
Before that the application worked fine without any warnings regarding the database. But now the debugger goes crazy with errors like this when I add entities to the context or try to save it:
+[PFUbiquityPeerRange(UbiquityMethods) peerRangeForLocalPrimaryKey:inStoreNamed:andEntityName:inManagedObjectContext:](71): CoreData: Ubiquity: Error or too many ranges for entity named: Room, ranges: (
"<PFUbiquityPeerRange: 0x627e0c0> (entity: PFUbiquityPeerRange; id: 0x627c830 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p12> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e300> (entity: PFUbiquityPeerRange; id: 0x627cfc0 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p13> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e350> (entity: PFUbiquityPeerRange; id: 0x627cfd0 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p21> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e3a0> (entity: PFUbiquityPeerRange; id: 0x627d300 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p42> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e3f0> (entity: PFUbiquityPeerRange; id: 0x627d310 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p49> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e440> (entity: PFUbiquityPeerRange; id: 0x627cea0 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p66> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e490> (entity: PFUbiquityPeerRange; id: 0x627ceb0 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p69> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e4e0> (entity: PFUbiquityPeerRange; id: 0x627cec0 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p75> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e530> (entity: PFUbiquityPeerRange; id: 0x627d120 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p82> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e580> (entity: PFUbiquityPeerRange; id: 0x627d130 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p94> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e5d0> (entity: PFUbiquityPeerRange; id: 0x627d140 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p96> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e620> (entity: PFUbiquityPeerRange; id: 0x627d150 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p97> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e670> (entity: PFUbiquityPeerRange; id: 0x627d160 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p132> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e6c0> (entity: PFUbiquityPeerRange; id: 0x627d170 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p140> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e710> (entity: PFUbiquityPeerRange; id: 0x627d180 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p156> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e760> (entity: PFUbiquityPeerRange; id: 0x627d190 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p157> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e7b0> (entity: PFUbiquityPeerRange; id: 0x627cd10 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p163> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e800> (entity: PFUbiquityPeerRange; id: 0x627cd20 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p177> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e850> (entity: PFUbiquityPeerRange; id: 0x627cd30 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p186> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e8a0> (entity: PFUbiquityPeerRange; id: 0x627cd40 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p192> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e8f0> (entity: PFUbiquityPeerRange; id: 0x627cd50 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p198> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e940> (entity: PFUbiquityPeerRange; id: 0x627cd60 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p199> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e990> (entity: PFUbiquityPeerRange; id: 0x627cd70 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p217> ; data: <fault>)",
"<PFUbiquityPeerRange: 0x627e9e0> (entity: PFUbiquityPeerRange; id: 0x627cd80 <x-coredata://A3F63A39-9034-4F81-8B35-911CC481B6C5/PFUbiquityPeerRange/p222> ; data: <fault>)")
, error: (null)
After throwing lot's of errors, I receive a memory warning and then the app crashes. I spent lots of hours but can't find anything about the UbiquityMethods additions or figure out the actual cause of the errors. Again: Before using the code from the CoreData Recipes sample project for creating the NSManagedObjectContext and the NSPersistantStoreCoordinator the app worked just fine.
I'd appreciate any help and of course I will keep you up to date on the topic!
Best Benjamin
回答1:
Check that you are correctly setting keys in your entitlements file and set correct values for NSPersistentStoreUbiquitousContentNameKey and NSPersistentStoreUbiquitousContentURLKey keys when configuring your NSPersistentStoreCoordinator instance. see I'm not getting the NSPersistentStoreDidImportUbiquitousContentChangesNotification (with code sample) for sample
回答2:
It's a bit of an old post, but it should still be able to clear things up a bit.
http://mentalfaculty.tumblr.com/post/25241910449/under-the-sheets-with-icloud-and-core-data
来源:https://stackoverflow.com/questions/8559305/weird-errors-using-coredata-with-icloud