Cocoa Programming for OS X: The Big Nerd Ranch Guide
by Aaron Hillegass, Adam Preble, Nate Chandler
Connecting the Remove Button
Next, you will connect the Remove button to the remove(_:) method on the array controller. This will be much the same as connecting the Add Employee button, but there are some additional considerations, as you will see.
Control-drag from the Remove button to Array Controller and set the action to remove:.
Run the application. Add two employees and give them pleasant names. Select the first one and click Remove. Contrary to your notions of all that is good and right in the world, the second employee has been removed! Now that nothing is selected, try clicking Remove once more. Even though no rows are selected, a row will be removed! What is going on here?
The array controller’s remove(_:) method removes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access