Advanced Mac OS X Programming

Advanced Mac OS X Programming is an important and unique book, because most Mac programming books focus mainly on frameworks like Cocoa or Carbon (for example the essential Cocoa: Programming for OS X written by one of the authors). This book instead covers everything that would usually be found in a BSD programming book, with the Mac OS X specifics added on top: its proprietary filesystem and a number of low-level APIs.
Obviously this is not a book for beginners, but anyone with a bit of Unix experience should feel right at home.
The first part of the book feels like an operating systems text: it talks about the compiler, libraries, memory management, and debugging. Everything is very Unix-like, but with all the Mac OS X-specific additions such as optimizations, fat binaries, frameworks, and bundles.
I particularly liked the chapter on libraries, which clearly analyzes what can be done with traditional Unix and compares dynamic library usage through NSBundle, NSModule, or dlopen(). The latter is used on other Unix systems, but only in Mac OS X 10.4 did it become a native API. Some time ago I worked on a program that used dlopen() and had been designed on Linux: even the simple tip I found in this book about printing to stdout when libraries were loaded would have been very useful (DYLD_PRINT_LIBRARIES).
The three filesystem chapters are also very interesting, because beyond reviewing the typical functions for reading and writing files, they cover all the attributes and metadata a file can have. With Mac OS X we are at historic highs in metadata volume because in addition to classic POSIX and owner permissions, there are Finder attributes, resource forks, extended attributes, ACLs, and more. Unfortunately, all of this cannot be handled by a single API, but by a mix of BSD, Carbon, and Cocoa. If you are picky, doing a correct backup is not exactly child’s play.
These are only the first examples. This is a book that does not need to be read from beginning to end: almost every chapter has content that does not depend on the others, making it very convenient to use as a reference for the future. Topics like Directory Services or Launchd may not interest us right now, but sooner or later they will deserve a read.