我正在使用CKSIncrementalStore。
我的数据模型是:
所有属性都是可选的。
我可以创建一个客户端,之后创建一个项目,我将客户端添加为关系。
像这样:
project.client = client
只要我只将同一个客户端添加到一个项目中,它就可以正常工作。每次我尝试将客户端添加到多个项目时,它都会给我这个错误:
Error Domain=NSCocoaErrorDomain Code=1550 "The operation couldn’t be completed. (Cocoa error 1550.)" UserInfo=0x1700ff000 {NSValidationErrorObject=<TimeTarget.Client: 0x1742a9d80> (entity: Client; id: 0x1706226c0 <x-coredata://5190F80A-6F0D-453D-9651-D4C827B299B1-2205-0000008CA6B29B34/Client/p6568F8E8-DF69-485C-BE84-B68261BA60F8> ; data: {
billable = 0;
color = 0;
defaultHourRate = 0;
name = Byyy;
projects = (
"0x17062c760 <x-coredata:///Project/tFDBB182C-7A2C-4E13-9AC3-080B305B10AB6>",
"0xd000000000040002 <x-coredata://27D63876-D016-436C-B8DD-99C0B8A9587A/Project/p1>"
); }), NSValidationErrorValue=Relationship 'projects' on managed object (0x1742a9d80) <TimeTarget.Client: 0x1742a9d80> (entity: Client; id: 0x1706226c0 <x-coredata://5190F80A-6F0D-453D-9651-D4C827B299B1-2205-0000008CA6B29B34/Client/p6568F8E8-DF69-485C-BE84-B68261BA60F8> ; data: {
billable = 0;
color = 0;
defaultHourRate = 0;
name = Byyy;
projects = (
"0x17062c760 <x-coredata:///Project/tFDBB182C-7A2C-4E13-9AC3-080B305B10AB6>",
"0xd000000000040002 <x-coredata://27D63876-D016-436C-B8DD-99C0B8A9587A/Project/p1>"
); }) with objects {(
<TimeTarget.Project: 0x1702a2b20> (entity: Project; id: 0x17062c760 <x-coredata:///Project/tFDBB182C-7A2C-4E13-9AC3-080B305B10AB6> ; data: {
billable = 0;
client = "0x1706226c0 <x-coredata://5190F80A-6F0D-453D-9651-D4C827B299B1-2205-0000008CA6B29B34/Client/p6568F8E8-DF69-485C-BE84-B68261BA60F8>";
color = 0;
defaultHourRate = 0;
name = "\U00c5\U00e5\U00e5\U00e5";
}),
<TimeTarget.Project: 0x1700dd730> (entity: Project; id: 0xd000000000040002 <x-coredata://27D63876-D016-436C-B8DD-99C0B8A9587A/Project/p1> ; data: {
billable = 0;
"cks_LocalStore_Attribute_ChangeType" = 0;
"cks_LocalStore_Attribute_EncodedValues" = <62706c69 73743030 d4010203 04050649 4a582476 65727369 6f6e5824 6f626a65 63747359 24617263 68697665 72542474 6f70>;
"cks_LocalStore_Attribute_RecordID" = "F8288FC8-8CBC-4B19-B2A5-F0FD8C19F109";
client = "0xd000000000040000 <x-coredata://27D63876-D016-436C-B8DD-99C0B8A9587A/Client/p1>";
color = 0;
defaultHourRate = 0;
name = Iiii;}) )}, NSValidationErrorKey=projects, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1550.)}
我将NSManagedObjectContext存储在sharedManager中,所以我在任何地方都使用相同的NSManagedObjectContext。
可能有什么问题? :)