2
votes

I'm creating a persistent store coordinator like this:

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Mydatabase.sqlite"];
NSError *error = nil;
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
      if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])

The issue is that as soon as I issue a save on any managed object context it fails with the following error:

May 15 17:46:18 xx-iPad @WorkMail[2807] <Warning>: Core Data: annotation: -executeRequest: encountered exception = Updating max pk failed:  with userInfo = {
        NSSQLiteErrorDomain = 14;
    }
May 15 17:46:18 xx-iPad @WorkMail[2807] <Warning>: Core Data: annotation: -executeRequest: encountered exception = Updating max pk failed:  with userInfo = {
        NSSQLiteErrorDomain = 14;
    }
May 15 17:46:18 xx-iPad @WorkMail[2807] <Warning>: Core Data: annotation: -executeRequest: encountered exception = Updating max pk failed:  with userInfo = {
        NSSQLiteErrorDomain = 14;
    }

This is one error, another erorr is error 21 with an authorization denied error.

When the passcode lock is not enabled, this does not occur. I am writing to core data from a background thread using a single persistent store coordinator.

1
I've worked out what this is. The problem wasn't a core data problem but rather the fact that when the passcode lock was enabled the data protection was enabled to the maximum level which was preventing any writes to any files in the application documents directory. The issue was caused by another team member changing the app ID. So if you hit this check your app ID and developer certificate properties. - Lee
Hey @Lee! Consider posting this as an answer to your own question. - steveluscher

1 Answers

1
votes

I've worked out what this is. The problem wasn't a core data problem but rather the fact that when the passcode lock was enabled the data protection was enabled to the maximum level which was preventing any writes to any files in the application documents directory. The issue was caused by another team member changing the app ID. So if you hit this check your app ID and developer certificate properties.