O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required