Create the Controller

The first step to using bindings is to create a controller object. To create a controller object, select a controller from Interface Builder’s Controllers Palette and drag it to the nib file window. If you’re working through this example, drag an array controller to the nib file window. I named my array controller InputDeviceMenuController. You can give your controller a different name if you want.

After creating the array controller you must specify what the array controller is going to manage. For this example the array controller is going to manage the HID devices connected to the user’s computer. The InputController class stores the device list so you must make a connection from the array controller to the InputController class. In Interface Builder select the array controller and control-drag to the InputController instance in the nib file window. The information panel will show the list of outlets for the array controller. Select the content outlet and click the Connect button.

At this point you’ve connected the controller to the object holding the array. Now you must tell the controller what types of objects are in the array. Select the array controller from the nib file and press Cmd-1. Set the object class name to InputDevice, which tells the array controller it’s managing an array of InputDevice objects.

At the bottom of the information panel you will see a list of keys. The controller uses keys to bind data to user interface elements. Click the Add button to add a key to the list. Add the following keys: manufacturer, productID, productName, serialNumber, transportKey, usage, usagePage, usbLocationID, vendorID, and version.

Next (Bind the Pop-up Menu)

Previous (The Example Program)