Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7534209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:57:07+00:00 2026-05-30T05:57:07+00:00

When I add a persistent store with NSPersistentStoreUbiquitousContentNameKey and NSPersistentStoreUbiquitousContentURLKey my application crashes every

  • 0

When I add a persistent store with NSPersistentStoreUbiquitousContentNameKey and NSPersistentStoreUbiquitousContentURLKey my application crashes every second time with an exception. This happens during the call to addPersistentStoreWithType:configuration:URL:options:error:

The stack trace looks like this:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
  reason: 'An NSManagedObject of class 'PFUbiquityPeer' must have a valid
  NSEntityDescription.'
*** First throw call stack:
(
     0   CoreFoundation   0x00007fff8b35ffc6 __exceptionPreprocess + 198
     1   libobjc.A.dylib  0x00007fff83368d5e objc_exception_throw + 43
     2   CoreData         0x00007fff82c28c06 -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:] + 182
     3   CoreData         0x00007fff82d4d3dc +[PFUbiquityPeer(UbiquityMethods) peerForPeerID:inManagedObjectContext:createIfMissing:] + 364
     4   CoreData         0x00007fff82d4f809 -[PFUbiquityPeerRange(UbiquityMethods) loadFromStoreMetadataDictionary:] + 105
     5   CoreData         0x00007fff82d80372 -[PFUbiquityStoreMetadataMedic recoverPeerRangesWithError:] + 418
     6   CoreData         0x00007fff82d80ab5 -[PFUbiquityStoreMetadataMedic recoverMetadataWithError:] + 1749
     7   CoreData         0x00007fff82d831dc -[PFUbiquitySetupAssistant performPostStoreSetupWithStore:error:] + 732
     8   CoreData         0x00007fff82c04001 -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 3537
     9   MyApp            0x000000010323de60 -[AppDelegate persistentStoreCoordinator] + 4224
     10  MyApp            0x000000010323e43f -[AppDelegate managedObjectContext] + 95
     11  Foundation       0x00007fff863b5384 _NSGetUsingKeyValueGetter + 62
     12  Foundation       0x00007fff863b5339 -[NSObject(NSKeyValueCoding) valueForKey:] + 392
     13  Foundation       0x00007fff863d4dc6 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 348
     14  AppKit           0x00007fff87fb1ae2 -[NSBinder _valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:] + 654
     15  AppKit           0x00007fff87fb17cc -[NSBinder valueForBinding:resolveMarkersToPlaceholders:] + 171
     16  AppKit           0x00007fff87fb143a -[NSObjectParameterBinder _updateObject:observedController:observedKeyPath:context:] + 1181
     17  AppKit           0x00007fff87fa3777 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 591
     18  AppKit           0x00007fff87f9ca89 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1079
     19  AppKit           0x00007fff87f9309f loadNib + 322
     20  AppKit           0x00007fff87f9259c +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
     21  AppKit           0x00007fff87f924b7 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
     22  AppKit           0x00007fff87f923fa +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
     23  AppKit           0x00007fff882059b3 NSApplicationMain + 398
     24  MyApp            0x0000000103239522 main + 34
     25  MyApp            0x00000001032394f4 start + 52
     26  ???              0x0000000000000003 0x0 + 3
)
terminate called throwing an exception(lldb)

When I don’t add the NSPersistentStoreUbiquitousContentNameKey and NSPersistentStoreUbiquitousContentURLKey options to the store everything works without problems. I get this exception only on every second application launch. For testing purposes (and because I thought that the issue could have something to do with concurrency), I removed all Core Data access and bindings from the main NIB file and tried to access the Core Data stack programmatically inside the applicationDidFinishLaunching: method. In the first test I did this directly, the second time I performed the selector (managedObjectContext) after a delay of 10 seconds. Both tests resulted in the same exception on every second application launch.

The (slightly shortened for this example) managedObjectContext method looks like this:

- (NSManagedObjectContext *)managedObjectContext
{
  if (managedObjectContext_)
  {
    return managedObjectContext_;
  }

  NSPersistentStoreCoordinator *coordinator = self.persistentStoreCoordinator;
  if (!coordinator)
  {
    return nil;
  }

  NSManagedObjectContext *moc = [[NSManagedObjectContext alloc] 
    initWithConcurrencyType:NSMainQueueConcurrencyType];
  [moc performBlockAndWait:
   ^{
    moc.mergePolicy = [[NSMergePolicy alloc] 
      initWithMergeType:NSMergeByPropertyObjectTrumpMergePolicyType];
    [moc setPersistentStoreCoordinator:coordinator];

    [[NSNotificationCenter defaultCenter] addObserver:self
      selector:@selector(mergeChangesFrom_iCloud:) 
      name:NSPersistentStoreDidImportUbiquitousContentChangesNotification 
      object:coordinator];
  }];
  managedObjectContext_ = moc;

  return managedObjectContext_;
}

The relevant part of persistentStoreCoordinator is:

  NSMutableDictionary *storeOptions = [NSMutableDictionary dictionary];
  [storeOptions setObject:[NSNumber numberWithBool:YES] 
    forKey:NSMigratePersistentStoresAutomaticallyOption];
  [storeOptions setObject:[NSNumber numberWithBool:YES] 
    forKey:NSInferMappingModelAutomaticallyOption];

  NSURL *url = [NSURL fileURLWithPath:[applicationSupportDirectory 
    stringByAppendingPathComponent:kJCMyAppDatabaseFilename]];
  NSURL *ubiquityURL = [[NSFileManager defaultManager] 
    URLForUbiquityContainerIdentifier:nil];
  if (ubiquityURL)
  {
    JCDLog(@"User has iCloud enabled.");
    [storeOptions setObject:@"com.juicycocktail.myapp" 
      forKey:NSPersistentStoreUbiquitousContentNameKey];
    [storeOptions setObject:[NSURL fileURLWithPath:[[ubiquityURL path] 
      stringByAppendingPathComponent:kJCMyAppDatabaseFilename]] 
      forKey:NSPersistentStoreUbiquitousContentURLKey];       
  }

  persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] 
    initWithManagedObjectModel:mom];
  NSPersistentStoreCoordinator *psc = persistentStoreCoordinator_;

  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
  (dispatch_block_t)^{
    [psc lock];
    if (![psc addPersistentStoreWithType:kJCMyAppStoreType
      configuration:nil URL:url options:storeOptions error:&error])
    {
      dispatch_async(dispatch_get_main_queue(),
      ^{
        [[NSApplication sharedApplication] presentError:error];
        persistentStoreCoordinator_ = nil;

        return;
      });
    }    
    [psc unlock];

    dispatch_async(dispatch_get_main_queue(),
    ^{
      JCDLog(@"asynchronously added persistent store!");
      [[NSNotificationCenter defaultCenter]
        postNotificationName:@"RefetchAllDatabaseData"
        object:self userInfo:nil];
    });
  });

  return persistentStoreCoordinator_;

I guess that the PFUbiquityPeer class could’ve something to do with Core Data’s transaction logs that are kept in iCloud’s mobile documents folder, but I still can’t find the real cause for this issue. Any help how to track the root of this exception is highly appreciated as I’m already getting nuts. Especially a workaround or even a solution would be very helpful for me. I’m also glad if someone has a hint how to at least track down this exception.

Note: I also filed a bug in case this is an API bug (rdar://10892613).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:57:08+00:00Added an answer on May 30, 2026 at 5:57 am

    Rebooting OS X solved the issue. This reminds me of an IT Crowd running gag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Afternoon all, I tried to add a second data entity to the persistent store
I am trying to add objects to a persistent store in Core Data. When
I add my page top link button like this: <a name=top></a> . . .
I add this class to library/My/Validate/PasswordConfirmation.php <?php require_once 'Zend/Validate/Abstract.php'; class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract {
I use Core Data to maintain a persistent store, and the database can grow
We would like to start using Google Cloud Storage as a persistent store for
I have a very specific application where I need an auto-increment variable with persistent
I'm looking for a solution to add persistence to my native-code application. It should
So, I want to store a dictionary in a persistent file. Is there a
I'd like to add an editor to an RCP application. I need to leverage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.