Deleting an object in NSArrayController
-
20-09-2019 - |
Question
I have an NSTableView
which gets its data from an NSArrayController
and I need to delete the currently selected row. I know NSManagedObjectContext
has a deleteObject:
method but, I can't think of how to delete it from the NSArrayController
.
Solution
Use the NSArrayController
's remove:
action.
OTHER TIPS
To remove programmatically
[NSArrayController removeObjectAtArrangedObjectIndex:NSInteger];
or
[NSArrayController removeObjectAtArrangedObjectIndexes:NSIndexset];
@NewStack's answer in Swift 3:
ArrayController.remove(atArrangedObjectIndex: Int)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow