0

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

benjamin.ludwig
  • 1,575
  • 18
  • 28
  • Are you sure you've setup connection to iCloud correctly? Check out this SO question - http://stackoverflow.com/questions/7768528/im-not-getting-the-nspersistentstoredidimportubiquitouscontentchangesnotificati it helped me to get updates from iCloud (and now I'm struggling with merging changes I get from iCloud) – Kostiantyn Sokolinskyi Dec 20 '11 at 09:47

2 Answers2

0

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

I make my mark
  • 841
  • 6
  • 13
0

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

Community
  • 1
  • 1
  • I kind of solved the problem I mentioned. I think the reason was that I prefilled the database with a lot of data when the app started for the first time. Now that I leave it empty in the beginning the errors disappeared (now facing some new ones, but finally can sync something). – benjamin.ludwig Jan 04 '12 at 12:50
  • I also have the problems with pre-filled data. I need to pre-fill DB with default "categories". If the internet connection is slow (e.g. 3G) the second device will have 2 sets of same categories after some time. Probably I will try to intervene merge procedure and check names of the categories. What are your new problems? – Kostiantyn Sokolinskyi Jan 18 '12 at 15:13
  • here is what I do now: If iCloud is going to be enabled for the first time I create two contexts. One for the old database and one for the new iCloud-enabled. Then I transfer all the old data to the new context (took a lot of migration code). On a second device starting from zero all the data appeares after some time (often only a few seconds). That solved the problem with the prefilled DB. I'm still getting memory warnings when iCloud starts synching, especially on the iPod touch 4g. I'm still checking what's the cause, maybe it's my fault. – benjamin.ludwig Jan 30 '12 at 12:26
  • Thanks for the information! But how do you find whether iCloud is being enabled for the first time or not? And what if the second device starts offline? I've found a similar approach - https://devforums.apple.com/message/609574#609574 trying it out right now – Kostiantyn Sokolinskyi Jan 31 '12 at 05:40
  • I've posted my problem here - http://stackoverflow.com/questions/9097541/icloud-coredata-how-to-avoid-pre-filled-data-duplication as I've failed to find a way to solve it – Kostiantyn Sokolinskyi Feb 01 '12 at 16:02
  • ok I'll have a look at your post. For now I'll mark your answer as accepted and stop posting more comments here... – benjamin.ludwig Feb 06 '12 at 12:03