I have an iPad app that I use MagicalRecord to save the Core Data entities in a SQLite d/b. Everything was working fine until I decided to use FTASync to sync the Core Data with Parse.com.

Part of the requirements of FTASync are that you have to use mogenerator to generate the entity class files. Now, I'm getting this error:

2013-12-14 12:38:59.375 foo[5451:70b] Failed to save to data store: The operation couldn’t be completed. (Cocoa error 1560.)
2013-12-14 12:38:59.380 foo[5451:70b]   DetailedError: {
    NSLocalizedDescription = "The operation couldn\U2019t be completed. (Cocoa error 1570.)";
    NSValidationErrorKey = objectId;
    NSValidationErrorObject = "<PreferenceData: 0x1149c3a0> (entity: PreferenceData; id: 0x114a7eb0 <x-coredata://03C39CC9-AC6C-4E56-BB5A-67038ACB6801/PreferenceData/p25> ; data: {\n    aAddlSvcs1 = \"\";\n    aAddlSvcs10 = \"\";\n    aAddlSvcs11 = \"\";\n    aAddlSvcs12 = \"\";\n    aAddlSvcs2 = \"\";\n    aAddlSvcs3 = \"\";\n    aAddlSvcs4 = \"\";\n    aAddlSvcs5 = \"\";\n    aAddlSvcs6 = \"\";\n    aAddlSvcs7 = \"\";\n    aAddlSvcs8 = \"\";\n    aAddlSvcs9 = \"\";\n    aApptInterval = \"\";\n    aDeleteOldAppts = \"-1\";\n    aDoubleBooking = \"-1\";\n    aHideHelpBtns = 0;\n    aHourFormat12 = 0;\n    aShopCloses = 1200;\n    aShopOpens = 1000;\n    createdHere = 1;\n    deleted = 0;\n    objectId = nil;\n    syncStatus = 2;\n    updatedAt = nil;\n})";
}

If I want to sync my Core Data store using FTASync, I have to use mogenerator.

So, what exactly is this telling me, other than "it couldn't be completed"? How do I fix this?

UPDATED: This is an image from the XCode Data Model Inspector

enter image description here

有帮助吗?

解决方案

You have defined some validation rules in the xcdatamodel with the model editor: minimum/maximum values, required relationship, min/max string length.

When you insert objects via a GUI, you'll see immediate feedback when you try to create an object that fails validation. But if you create or modify an object in code, you won't see an error unless you try to save the Managed Object Context.

You can invoke -validateForUpdate: (or -validateForInsert: or -validateForDelete:) within the code that's creating your PreferenceData instance. Invoke it multiple times as you build the object, and you'll see where you're going wrong.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top