In my application I add objects directly to an ArrayController. When I want to clean all items I do:
[[downloadItemsController content] removeAllObjects];
This command however does not refresh the TableView the arraycontroller is bound to. If I remove all items and add another new items I only see that item. That is fine but if I don't add anything I still have all my items in the table.
If I do
[downloadItemsController prepareContent];
all old items are removed from the tableview but than I will get an new and empty item I can edit. I don't want that and because one of my columns has a checkboxcell I always get an row with a checkbox.
I just need an empty table with no items after I remove all existing items.
To quickly remove all the objects from an NSArrayController
object:
NSRange range = NSMakeRange(0, [[anArrayController arrangedObjects] count]);
[anArrayController removeObjectsAtArrangedObjectIndexes:[NSIndexSet indexSetWithIndexesInRange:range]];
The bindings should update automatically. See original SO answer.
This is because you're modifying the controller's content "behind its back." Try using the array controller's -removeObjects: method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With