O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

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

How the Quick Reference Was Generated

You’d have to be a madman to write this book’s quick reference by hand. Madmen we are not, so following the example of David Flanagan, author of O’Reilly’s Java in a Nutshell, Mike wrote a program that would take care of most of the tedious work.

The idea is to attack the problem in two stages. In the first stage, the code enumerates each header file of each Framework that is to be ripped (Foundation and AppKit) and runs each line of each header through a parser. This parser would look for key elements that identify parts of the header, such as @interface, + for class methods, - for instance methods, and so forth. Every discovered element was assembled into a cross-linked hierarchy of framework names, class names, or method names. When all headers had been processed, the hierarchy was output into a property list file, which, at the end of the day, weighed in at just over 41,500 lines of text!

Stage two involved reading the contents of this file and running it through several formatting routines that output the XML-formatted text required by the O’Reilly production team.

Each class has a little class hierarchy figure. These figures were autogenerated by drawing into a view (using NSBezierPath) and saving the PDF representation of the view contents to a file. The input data for the program that did all of the drawing was the same property list used to create the API quick reference entries.

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