delete-row - 无法撤消或重做将行添加到 NSOutlineView 的操作
问题描述
我的大多数撤消/重做操作都已停止工作。我写了一个简单的例子。
aNewNoteFor 成功地将 OutlineItem 添加到其兄弟的父级的子级,并将其插入到其兄弟级之后的 OutlineView 行中。
deleteAChild:应该删除该行并将其从其父级的子级中删除。
但撤消或重做均未启用。
- (void)aNewNoteFor:(OutlineItem*) sibling
{
//Ignore note. it's unimportant
Note* note = [self.document makeDraft:YES];
OutlineItem* newChild = [[OutlineItem alloc]initWithNote:note];
NSInteger index = [sibling.parent.children indexOfObject:sibling] +1;
[sibling.parent.children insertObject:newChild atIndex:index];
newChild.parent = sibling.parent;
[_document updateChangeCount:NSChangeDone];
[_outlineOutlet reloadData];
[_undoManager registerUndoWithTarget:self selector:@selector(deleteAChild:) object:newChild];
}
-(void)deleteAChild: (OutlineItem*)child
{
OutlineItem* parent = child.parent;
[parent.children removeObject:child];
[_outlineOutlet reloadData];
[_undoManager registerUndoWithTarget:self selector:@selector(aNewNoteFor:) object:parent];
}
''''
解决方案
推荐阅读
- python - 如何将“额外”参数传递给撰写函数
- java - 那个菜单叫什么?(智能理念)
- time-complexity - 如果已知 n 有界到一个常数,时间复杂度是 O(1) 还是 O(n)?
- html - 如果用户选择另一个选项卡,则更改网页的标题
- microsoft-graph-api - MS Teams Adaptive Cards 链接到当您不是成员时不会触发“加入团队”工作流的频道
- python - 有没有办法在python中对整数和字符串的并行列表进行排序?
- c# - 使用取消标记的 C# 异步/并行编程
- apache-kafka - 充分利用 kafka-node
- python - 如果来自另一个数据框的列和来自原始数据框的列具有匹配值,则在原始数据框中创建一个新列
- python - 随着数据帧大小的增加,dask 性能下降