O'Reilly logo

Cocoa® Programming for Mac OS® X For Dummies® by Erick Tejkowski

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

Chapter 18. Cocoa Bindings

In This Chapter

  • Understanding bindings

  • Working on a project with bindings

  • Using KVC and KVO to make your bindings work

  • Adding bindings to an existing project

Whenever you create a Cocoa application the traditional way, you implement a Model class that manages data, an interface that users interact with, and a Controller class that ties the two together. This is all well and good, but Objective-C saves you from a substantial bit of coding and hassle by permitting you to bypass the Controller class altogether.

Bindings let you bridge items in your interface directly to data in your Model classes. This is handy because Objective-C handles the tasks of keeping your interface updated and, more importantly, you don't have to. That means less coding work for you and less chance of creating bugs.

This chapter explains what bindings are and why you use them. Then, it describes some of the technology behind bindings (namely KVC and KVO). KVC and KVO are two complementary technologies that you can use to generically get and set the values of instance variables. Finally, you create a project that uses bindings instead of code to control an interface in your application.

Note

Bindings is an advanced topic that is also voluminous, and as such, you have to do some exploration on your own to master the wild and wooly world of bindings. This chapter only scratches the surface of what you can do with bindings. You can bind all sorts of elements in your interface to many different ...

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