Thursday, 19 September 2013

NSOutlineView add/remove items

NSOutlineView add/remove items

I use NSOutlineView in the my app. And I have some problems with
add/remove items. If I do
[outlineView beginUpdates];
[outlineView removeItemsAtIndexes:[NSIndexSet
indexSetWithIndex:[[[selectedItem parent] children]
indexOfObject:selectedItem]] inParent:[selectedItem parent]
withAnimation:NSTableViewAnimationSlideRight];
[outlineView endUpdates];
Then I get crash with this log:
NSTableView Error: Insert/remove/move only works within a
-beginUpdates/-endUpdates block.
But If I do
[[selectedItem parent] removeObjectFromChildren:selectedItem];
[outlineView reloadData];
Then to add to operating normally, but if I do remove operating then I get
non-selectable cell. It's look like outlineView doesn't clear context. How
I can fix it?

No comments:

Post a Comment