Cocoa : Remove Item from NSArrayController
Posted
by Holli
on Stack Overflow
See other posts from Stack Overflow
or by Holli
Published on 2010-05-30T15:29:06Z
Indexed on
2010/05/30
15:32 UTC
Read the original article
Hit count: 283
I have a NSArrayController bound to a NSTableView. With this I have the typical Add/Remove buttons.
While Adding an item is very straight forward (I call a method, create an object with default values and add it) I have problems deleting objects from the controller. I know I can do this the easy way when connecting the button with the remove action from the ArrayController. But this is not what I want. I need to remove the object manually because I have some additional code to process.
Anway, removing objects seems far more complcated then I expected. It already tried:
NSArray *items = [doToItemsArrayController selectedObjects];
[doToItemsArrayController removeSelectedObjects:items];
or
NSIndexSet *iSet = [doToItemsArrayController selectionIndexes];
[doToItemsArrayController removeSelectionIndexes:iSet];
None of them seems to work. How do I remove the selected Object from an NSArrayController with Objective-C code?
© Stack Overflow or respective owner