I have an NSArrayController that is bound to a NSTableView and the datasource is an Array. I can't seem to get a remove to remove objects from both the Array and NSTableView.
I can use the following to delete the object from the NSTableView, but it is not removed from the datasource Array or NSArrayController
projectsTable.removeRows(at: [projectsTable.selectedRow], withAnimation:.effectFade)
I have also tried the following remove commands on the NSArrayController with no success.
let prjremove = projectsArrayControler.selectedObjects
let didRemove =projectsArrayControler.removeSelectedObjects(prjremove!)
The removeSelectedObjects returns true, but a debug view shows the number of objects in the ArrayController not to have changed and there is no change in the NSTableView.
I was operating under the assumption that deleting an object or row from the NSTableView would delete the object from the datasource Array. Apparently that is not correct.
Your words of wisdom are appreciated.
Jim
removeSelectedObjects
:
Removes objects from the receiver’s current selection, returning YES if the selection was changed.
"Removes objects from the receiver’s current selection" means the objects are deselected.
Use func remove(contentsOf objects: [Any])
:
Removes objects from the receiver’s content collection.
or func remove(_ sender: Any?)
:
Removes the receiver’s selected objects from the content collection.