Reputation: 691
We are getting the following error on a small portion of our beta testers and haven't been able to find a clue of why this is happening:
Managed object store failed to create persistent store coordinator:
Error Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed.
(Cocoa error 256.)" UserInfo=0x1f5cd8b0
{NSUnderlyingException=authorization denied, NSSQLiteErrorDomain=23}
This happens after the app is launched in the background due to a location event and when we call addPersistentStoreWithType
. This is how I'm passing the options:
NSDictionary *persistentStoreOptions = [NSDictionary
dictionaryWithObjectsAndKeys:
NSFileProtectionNone, NSPersistentStoreFileProtectionKey, nil];
NSError *error;
if (![_persistentStoreCoordinator
addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeURL
options:persistentStoreOptions
error:&error]) {
...
}
Any clue on why this would happen only for a percentage of installs and the reason behind it?
Upvotes: 0
Views: 947
Reputation: 21254
Are you using Core Data across multiple threads? Any chance these users are getting multiple NSPersistentStoreCoordinator instances when they should not? I have seen this problem before, in particular with slower devices, and it turned out to be that the code controlling "lazy instantiation" of the persistent store coordinator was not as thread safe as it should be.
Upvotes: 1