我正在创建一个像这样的持久存储协调器:
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])
问题是,一旦我在任何托管对象上下文上发出保存,它就会失败并出现以下错误:
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;
}
这是一个错误,另一个错误是错误 21,授权被拒绝错误。
如果未启用密码锁定,则不会发生这种情况。我正在使用单个持久存储协调器从后台线程写入核心数据。