Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Core data NSLocalizedDescription=“操作无法完成。(Cocoa错误1550)。”_Core Data - Fatal编程技术网

Core data NSLocalizedDescription=“操作无法完成。(Cocoa错误1550)。”

Core data NSLocalizedDescription=“操作无法完成。(Cocoa错误1550)。”,core-data,Core Data,我有以下问题: 设置同一实体的元素之间的关系是可行的,但两个不同实体之间的关系往往会导致错误。以下是尝试保存时的错误输出: NSLocalizedDescription = "The operation couldn\U2019t be completed. (Cocoa error 1550.)"; NSValidationErrorKey = responsible; NSValidationErrorObject = "<Actor: 0x8876840> (entity:

我有以下问题:

设置同一实体的元素之间的关系是可行的,但两个不同实体之间的关系往往会导致错误。以下是尝试保存时的错误输出:

NSLocalizedDescription = "The operation couldn\U2019t be completed. (Cocoa error 1550.)";

NSValidationErrorKey = responsible;

NSValidationErrorObject = "<Actor: 0x8876840> (entity: Actor; id: 0x8875210 <x-coredata://599B45F7-F346-4674-B1B9-5BAEBD575E74/Actor/p2> ; data: {\n    belongings = \"<relationship fault: 0x8a0c660 'belongings'>\";\n    name = Sofie;\n    orderingValue = 2;\n    performsA = \"<relationship fault: 0x8a190d0 'performsA'>\";\n    performsC = \"<relationship fault: 0x8a19110 'performsC'>\";\n    performsI = \"<relationship fault: 0x8a19150 'performsI'>\";\n    performsR = \"<relationship fault: 0x8a19190 'performsR'>\";\n    responsible =     (\n        \"0x8884e10 <x-coredata://599B45F7-F346-4674-B1B9-5BAEBD575E74/Goal/p1>\"\n    );\n    supervisedBy = \"<relationship fault: 0x8a191f0 'supervisedBy'>\";\n    supervising = \"<relationship fault: 0x8a19230 'supervising'>\";\n    type = Person;\n})";

NSValidationErrorValue = "Relationship 'responsible' on managed object (0x8876840) <Actor: 0x8876840> (entity: Actor; id: 0x8875210 <x-coredata://599B45F7-F346-4674-B1B9-5BAEBD575E74/Actor/p2> ; data: {\n    belongings = \"<relationship fault: 0x8a0c660 'belongings'>\";\n    name = Sofie;\n    orderingValue = 2;\n    performsA = \"<relationship fault: 0x8a190d0 'performsA'>\";\n    performsC = \"<relationship fault: 0x8a19110 'performsC'>\";\n    performsI = \"<relationship fault: 0x8a19150 'performsI'>\";\n    performsR = \"<relationship fault: 0x8a19190 'performsR'>\";\n    responsible =     (\n        \"0x8884e10 <x-coredata://599B45F7-F346-4674-B1B9-5BAEBD575E74/Goal/p1>\"\n    );\n    supervisedBy = \"<relationship fault: 0x8a191f0 'supervisedBy'>\";\n    supervising = \"<relationship fault: 0x8a19230 'supervising'>\";\n    type = Person;\n}) with objects {(\n    <NSManagedObject: 0x8885d60> (entity: Goal; id: 0x8884e10 <x-coredata://599B45F7-F346-4674-B1B9-5BAEBD575E74/Goal/p1> ; data: {\n    concerning = \"<relationship fault: 0x8a1ba40 'concerning'>\";\n    conflictedBy = \"<relationship fault: 0x8a1c5c0 'conflictedBy'>\";\n    conflicting = \"<relationship fault: 0x8a1c600 'conflicting'>\";\n    higherLevelGoalAND = \"<relationship fault: 0x8a1c640 'higherLevelGoalAND'>\";\n    higherLevelGoalOR = \"<relationship fault: 0x8a1c680 'higherLevelGoalOR'>\";\n    lowerLevelGoalAND = \"<relationship fault: 0x8a1c6c0 'lowerLevelGoalAND'>\";\n    lowerLevelGoalOR = \"<relationship fault: 0x8a1c700 'lowerLevelGoalOR'>\";\n    name = \"Customer satisfaction\";\n    operationalization = \"<relationship fault: 0x8a1c740 'operationalization'>\";\n    orderingValue = 1;\n    responsibles =     (\n        \"0x8875210 <x-coredata://599B45F7-F346-4674-B1B9-5BAEBD575E74/Actor/p2>\"\n    );\n})\n)}";
ActorroverView.h

...
@interface ActorOverview : NSObject

{

NSMutableArray *allActors;

NSMutableArray *actorFetch;

NSManagedObjectContext *context;

NSManagedObjectModel *model;

}
@property (nonatomic, retain) NSManagedObjectContext *context;
...
-(void)relationshipBetweenActor:(Actor *)a andEntity:(NSManagedObject *)e withInfo:(NSString *)info action:(NSString *)action;
...
Actor:andEntity:withInfo:action:之间的关系在设置两个参与者之间的关系时可以正常工作

然而,当我在目标和参与者之间建立关系时,它失败了。参与者对某个目标负责

在ActorZoomViewController.m中

// Define the actor

ActorOverview *ao = [[ActorOverview alloc]init];

Actor *actorInZoom = [ao fetchActorWithOrderingValue:currentActor];



// Define the goal

GoalOverview *go = [[GoalOverview alloc]init];

NSArray *goals = [[GoalOverview defaultOverview]allGoals];

Goal *goalInZoom = [goals objectAtIndex:0];



// Adding a new relationship

[ao relationshipBetweenActor:actorInZoom andEntity:goalInZoom withInfo:@"" action:@"add"];



// Save

[[ActorOverview defaultOverview]saveChanges];
在ActorVerView.m中调用Actor:andEntity:withInfo:action:之间的关系

-(void)relationshipBetweenActor:(Actor *)a andEntity:(NSManagedObject *)e withInfo:(NSString *)info action:(NSString *)action

{
NSEntityDescription *ed = [e entity];

 if([[ed name] isEqualToString:@"Goal"])

     {

         if([action isEqualToString:@"add"])

         {

             NSLog(@"NEW relationship between Actor: %@ and Goal: %@", [a name], [e name]);

             [a addResponsibleObject:e];            

         }

         if([action isEqualToString:@"remove"])

         {

             NSLog(@"REMOVED relationship between Actor: %@ and Goal: %@", [a name], [e name]);

             [a removeResponsibleObject:e];

         }

     }

}
这将导致保存时出错


有谁能给我一些建议吗?

所以我发现我的实体处于不同的上下文中:上下文参与者:上下文目标:这些上下文由ActorVerView和GoalOverview处理。任何人都可以帮助我在正确的轨道上设置两者之间的关系吗?通过以下教程的组合将应用程序更改为使用单个NSManagedObjectContext:;尽管这些链接都不再有效,但它们帮助解决了类似的问题。非常感谢。
-(void)relationshipBetweenActor:(Actor *)a andEntity:(NSManagedObject *)e withInfo:(NSString *)info action:(NSString *)action

{
NSEntityDescription *ed = [e entity];

 if([[ed name] isEqualToString:@"Goal"])

     {

         if([action isEqualToString:@"add"])

         {

             NSLog(@"NEW relationship between Actor: %@ and Goal: %@", [a name], [e name]);

             [a addResponsibleObject:e];            

         }

         if([action isEqualToString:@"remove"])

         {

             NSLog(@"REMOVED relationship between Actor: %@ and Goal: %@", [a name], [e name]);

             [a removeResponsibleObject:e];

         }

     }

}