我尝试构建简单的贝塞尔曲线编辑器。型号和代码如下。 当我试图删除 node.bcpInData 或 node.bcpOutData 时,只删除了 node.originData ,完全没有任何意义。< / p>
这是我的模特:
这是 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;
})
任何帮助?
答案 0 :(得分:0)
在点控制器中选择了BcpInData和BcpOutData。这足够了
删除前[points removeSelectedObjects:@[pointData]];
。