シンプルなベジエ曲線エディターを構築しようとしています。以下のモデルとコード。node.bcpInDataまたはnode.bcpOutDataを削除しようとすると、 node.originDataのみが削除されます。魔女はまったく意味がありません。
これは私のモデルです:
delete:メソッドは次のとおりです。
-(void) delete:(id)sender {
[undoManager beginUndoGrouping];
[points willChangeValueForKey:@"arrangedObjects"];
NSMutableArray * nodesToDelete = [NSMutableArray array];
for (TPPointData * pointData in points.selectedObjects) {
NSLog(@"PointData %@", pointData);
NSLog(@"PointData.node = %@", pointData.node);
TPNode * node = pointData.node;
if (pointData == pointData.node.originData) {
//delete everything
[nodesToDelete addObject:pointData.node];
if (pointData.node.bcpInData!=nil) {
NSLog(@"deleting bcpInData: %@", pointData.node.bcpInData);
[moc deleteObject:pointData.node.bcpInData];
pointData.node = nil;
}
if (pointData.node.bcpOutData!=nil) {
NSLog(@"deleting bcpOutData: %@", pointData.node.bcpOutData);
[moc deleteObject:pointData.node.bcpOutData];
pointData.node = nil;
}
NSLog(@"deleting originData: %@", pointData.node.bcpOutData);
[moc deleteObject:pointData];
pointData.node = nil;
} else { //delete just object
[moc deleteObject:pointData];
pointData.node = nil;
}
NSLog(@"node: %@", node);
}
NSMutableArray * contoursToDelete = [NSMutableArray array];
for (TPNode * node in nodesToDelete) {
if (node.contour.nodes.count == 1) {
[contoursToDelete addObject:node.contour];
}
[moc deleteObject:node];
}
for (TPContour * contour in contoursToDelete) {
[moc deleteObject:contour];
}
[points didChangeValueForKey:@"arrangedObjects"];
[undoManager endUndoGrouping];
}
origin の削除を試みた後のリスト:
2013-02-03 12:11:34.849 AlwaysSmooth[42786:403] PointData <TPPointData: 0x105c06400> (entity: PointData; id: 0x100133810 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p327> ; data: {
node = "0x100133830 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Node/p328>";
x = "215.5";
y = "550.1667";
})
2013-02-03 12:11:34.850 AlwaysSmooth[42786:403] PointData.node = <TPNode: 0x105c13250> (entity: Node; id: 0x100133830 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Node/p328> ; data: {
attribute = nil;
bcpIn = "(...not nil..)";
bcpInData = "0x1001337b0 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p326>";
bcpOut = "(...not nil..)";
bcpOutData = "0x100133640 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p329>";
contour = "0x1001c8c20 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Contour/p282>";
next = "(...not nil..)";
originData = "0x100133810 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p327>";
prev = "(...not nil..)";
smooth = 1;
type = 2;
})
2013-02-03 12:11:34.851 AlwaysSmooth[42786:403] deleting bcpInData: <TPPointData: 0x100183d70> (entity: PointData; id: 0x1001337b0 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p326> ; data: {
node = "0x100133830 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Node/p328>";
x = "301.4023";
y = "544.7839";
})
2013-02-03 12:11:34.853 AlwaysSmooth[42786:403] deleting originData: (null)
2013-02-03 12:11:34.854 AlwaysSmooth[42786:403] node: <TPNode: 0x105c13250> (entity: Node; id: 0x100133830 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Node/p328> ; data: {
attribute = nil;
bcpIn = "(...not nil..)";
bcpInData = "0x1001337b0 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p326>";
bcpOut = "(...not nil..)";
bcpOutData = "0x100133640 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p329>";
contour = "0x1001c8c20 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Contour/p282>";
next = "(...not nil..)";
originData = nil;
prev = "(...not nil..)";
smooth = 1;
type = 2;
})
bcpOutDataを削除しようとさえしないのはなぜですか? 削除前の originDataは null です。削除後もbcpInDataとbcpOutDataはノード オブジェクトに存在します。元に戻すことは引き続き可能です。
bcpInDataまたはbcpOutDataコードのみを削除しようとすると、originDataのみが再度削除されます。
2013-02-03 12:29:13.526 AlwaysSmooth[42786:403] PointData <TPPointData: 0x100183d70> (entity: PointData; id: 0x1001337b0 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p326> ; data: {
node = "0x100133830 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Node/p328>";
x = "301.4023";
y = "544.7839";
})
2013-02-03 12:29:13.527 AlwaysSmooth[42786:403] PointData.node = <TPNode: 0x105c13250> (entity: Node; id: 0x100133830 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Node/p328> ; data: {
attribute = nil;
bcpIn = "(...not nil..)";
bcpInData = "0x1001337b0 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p326>";
bcpOut = "(...not nil..)";
bcpOutData = "0x100133640 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p329>";
contour = "0x1001c8c20 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Contour/p282>";
next = "(...not nil..)";
originData = "0x100133810 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p327>";
prev = "(...not nil..)";
smooth = 1;
type = 2;
})
2013-02-03 12:29:13.529 AlwaysSmooth[42786:403] node: <TPNode: 0x105c13250> (entity: Node; id: 0x100133830 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Node/p328> ; data: {
attribute = nil;
bcpIn = "(...not nil..)";
bcpInData = "0x1001337b0 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p326>";
bcpOut = "(...not nil..)";
bcpOutData = "0x100133640 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/PointData/p329>";
contour = "0x1001c8c20 <x-coredata://8E705B64-CB39-4FBD-B296-936E70835DC8/Contour/p282>";
next = "(...not nil..)";
originData = nil;
prev = "(...not nil..)";
smooth = 1;
type = 2;
})
何か助けはありますか?