1 year ago
#284266

WikipediaBrown
CoreData Batch Insert with Extra Keys (Cocoa error 1605.)
I am using CoreData
to insert an array of dictionaries ([[String: Any]]
) representing objects into a PersistentStore
. When inserting the objects, I get the error The operation couldn’t be completed. (Cocoa error 1605.)
. The next line printed to the console is:
Error Domain=NSCocoaErrorDomain Code=1605 "(null)" UserInfo={NSValidationErrorKey=date, NSValidationErrorObject=Bot}
I am creating the array of dictionaries from a JSON
object that has more keys than the corresponding ManagedObject
in CoreData
. Can I use NSBatchInsertRequest
with keys that aren't in the corresponding ManagedObject
?
Here is the code:
let batch: [[String: Any]] = getBatch()
let request = NSBatchInsertRequest(entity: Bot.entity(), objects: batch)
let insertResult = try self?.managedObjectContext.execute(request) as? NSBatchInsertResult
let result = insertResult?.result as? Bool
print(result?.description ?? "")
ios
swift
core-data
batch-processing
nsmanagedobjectcontext
0 Answers
Your Answer