Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

Faster, Easier Product Development: Delicious Library Takes Advantage of Cocoa Bindings

Wil Shipley is a leading-edge kind of guy. As the founder of the Omni Group, he was one of the first people to create outstanding software for the NeXT platform (and, later, for Mac OS X). In March, 2004, he left the Omni Group to co-found a software-development company with another Omni Group alumnus, Mike Matas.

And Wil and Mike like to do things their own way. For starters, their company is named Delicious Monster, after the Latin name of a tasty tropical fruit-bearing plant. Plus, their “office” is actually a large table at a Seattle coffee house, they depend on word-of-mouth recommendations for advertising, and they sell their product only on the Internet.

Their personal approach with Delicious Monster has already made the product a resounding success. With a small but talented development team (“we started with one and one-eighth programmers,” says Wil), the company designed and implemented Delicious Library, an innovative “visual card-catalog” program for keeping track of all your books, movies, music CDs, and computer games. The company’s web site started selling Delicious Library on November 8, 2004. One month later, it had amassed sales totaling nearly $250,000.



The application Delicious Library gets top marks for its user-friendliness, its devoted adherence to the Macintosh human-interface guidelines, and its imaginative uses of Macintosh platform technologies—for example, its ability to use an iSight camera to scan an item into the application’s database.

However, Wil singles out one Apple technology, Cocoa bindings, as being central to his company’s success so far.

The value of Cocoa bindings, he says, is that, “it makes it really easy for programmers to present data in a way that’s very clear and intuitive to the user. It makes every app look and feel like an iApp.”

First Experiences with Cocoa Bindings

Wil was already working on Delicious Library when he found out about Cocoa bindings. But, being a leading edge kind of guy, he took time out to investigate.

Wil says, “I knew nothing about it; the technology had just come out, there were no experts in it. So I just went to the ADC site, read through the docs, compiled the sample code—the process just went so smoothly. There’s tutorials, there’s tons of documents that give you a high-level overview—there’s much more than could be in any book. And with intelligent searching, you can find just what you need.

“When I started reading about Cocoa Bindings, I was amazed at what it sounded like they could do. So we thought we would see how hard it would be to switch the code we had to use Cocoa bindings.

“We rewrote everything in a day or two—I think we deleted over a thousand lines of code that just wasn’t needed any more.

“And when we got this new version working, it was doing more than the original version did. We found that the program just did multiple selections ‘for free’—and now, the delete function worked.”

How Cocoa Bindings Work

Cocoa bindings is a collection of technologies—introduced in Mac OS X v10.3 Panther, and enhanced in Mac OS X v.10.4 Tiger—that enables you (among other things) to implement much of the necessary infrastructure of an MVC (Model-View-Controller) architecture by “wiring” Interface Builder objects to each other. At the lowest level, it enables you to synchronize two variables or object attributes within your program such that whenever one of them is changed (by either the user or the application), Mac OS X changes the other one automatically.

By using Cocoa bindings in different ways, you can create a variety of useful automatic behaviors. For example, virtually every Cocoa application needs to keep two values synchronized—both a value in your program’s model and the value for its on-screen representation.

Before Cocoa bindings, Wil said, “You were always trying to keep them in sync, but there was always the possibility that you had missed at least one place where a change in one value needed to be mirrored by a change in the other. As a result, the two values would wander out of sync.

“One of the basic things that Cocoa bindings give you for free is that they keep the on-screen controls exactly in sync with your data, and you don’t have to say, ‘Oh, wait a minute, I need to remember that if I update it here in my model data, I also have to update the control value.’”

Live Searching

One of the main features of Delicious Library is its ability to let you find specific items in your collection quickly and easily. Searching is a simple two-step process: select the media type (for example, music) in the left panel, then start typing whatever comes to mind (artist name, song title, genre, whatever) in the search field at the bottom. The more you type, the fewer items from your collection are displayed. Wil calls this feature “live searching,” and users absolutely love it. According to Wil, when you use Cocoa bindings to implement live searching, it takes “about three lines of code” to get the job done.

Multiple Selections

By the way, Delicious Library doesn’t artificially limit the research process to one kind of media at a time. You can search multiple categories (for example, books and music) by shift-clicking multiple categories before you begin typing in the search field. When you implement automatic behaviors using Cocoa bindings, your application automatically handles multiple selections.

“What is amazingly cool,” Wil says, “is that Cocoa bindings handle multiple selections really, really well—better than most programs ever do. It’s so hard to do multiple selections correctly, but since Apple engineers were building it into the operating system, they decided to spend the time to do it right.”

When you use Cocoa bindings and configure them properly, you get another, more sophisticated multiple selection-related behavior—again, without writing any code. Delicious Library shows this behavior in action: When you select, for example, a Bob Marley CD from your collection, Delicious Library displays detailed information about that CD—artist name, CD title, a list of all the songs on the CD, and so on—in a detail panel on the right side of its window. When you select multiple CDs, however, what gets displayed depends on which CDs you selected. If both of them were recorded by Bob Marley, the artist field reads “Bob Marley” in black text, but if the CDs were recorded by different people, the same field reads “different artists,” this time in gray text. This is the kind of feature that makes the user say, “Wow, this is a really great application”—and Cocoa bindings makes this feature trivial to implement.

Master-Detail Interfaces

“Another place where you’ll commonly use Cocoa bindings,” says Wil, “is when you show users a list of items, and then they pick an item, and you show them more information about the item they picked.”

This is called a Master-Detail Interface, where the master interface contains a table view displaying your list of items, and the detail interface contains a view that displays more about the selected item. “In Delicious Library, when you click on a CD or a book in the middle panel and Delicious Library tells you about it in the right panel, that happens just by using Cocoa bindings—and the delete key works, and multiple selections work, and you don’t have to do anything extra to get all that.”

Cocoa Bindings as a Competitive Advantage

Wil says that the concept behind Cocoa bindings is very powerful, and the more you understand it, the more uses you find for it.

“It’s not just limited to the user interface,” he says. “It’s about keeping objects in sync with each other.”

In addition to the features, polish, and reliability that have been added to Delicious Library through the use of Cocoa bindings, Wil acknowledges that Cocoa bindings also gave his company a significant competitive advantage. It enabled him to design, implement, and release a full-featured, innovative product in just under eight months, which works out to about eight person-months of programming effort. He adds, “Without Cocoa bindings, it would have taken another four or five months, maybe more, to finish Delicious Library.”

And reducing your time-to-market by a full one-third is a competitive advantage that should make anybody take notice.

For more information on Delicious Library, see the Delicious Monster website.