Errata and Random Info for Advanced Mac OS X Programming, The Big Nerd Ranch Guide (Third Edition)
- Borkware »
- Advanced Mac OS X Programming
Found an error? Something not clear? Send it to
markd@borkware.com
Chapter 1 : C and Objective-C
- (page 7) Example 1-4 is called predef.m, even though the code itself is predef.mm since it has some C++ foobage (Thanks to Tyler Bindon)
- (page 22) figure 1-5 "Bitwise AND". The
A & Mask
example should have a result of zero. (Thanks to Bolot Kerimbaev)
- (page 27) The output of
bitmask
has ANOTHER_MASK repeated twice. It should only appear once . (Thanks to Tyler Bindon)
Chapter 2 : The Compiler
- (page 43) llvm-gcc is gcc parser and llvm code generation, not the other way around. (Thanks to Martin Pilkington)
- (page 46) Xcode4 moves the "Preprocessor" command around from version to version. Some versions have it under the jump bar in a section called "Generated Output" (as is in the book) other versions have it directly in the jump bar with "Preprocess", and it wasn't until fairly late in the game that Xcode4 even had a preprocess command.
Chapter 4 : Command-Line Programs
- (page 94)
argparse.m
's printing of the thing
variables on line 59 should be thing1, thing2, thing3);
(Thanks to Jérôme Paschoud)
- (page 97)
defargs.m
has a malformed #import.
(Thanks to Jérôme Paschoud)
Chapter 5 : Exceptions and Error Handling
- (page 128)
tail -f /var/system.log
should be looking at /var/log/system.log
. (Thanks to Philippe Casgrain)
- (page 130) Under AssertMacros.h: "if the label is not zero" should be "if the error code is not zero"what sucks. (Thanks to Bill Monk)
Chapter 6 : Libraries
- (pages 146 and 147) Which says objective-C bundles can and can't be unloaded. Regular bundles can be unloaded. Bundles containing Objective-C are a special case - they can be unloaded, but on a strict LIFO order, you can't have any leftover instances, plus anything like atexit handlers will keep the bundle resident. In general, you can assume that any Objective-C code loaded at runtime will be there forever. (Thanks to Tyler Bindon)
- (page 150) Example 6.10's title should be complexmessage.m. (Thanks to Craig Dooley)
Chapter 7 : Memory
- (page 159) The example code function is "frobulate()" but is referenced as "borkulize()" in the text below. (Thanks to Michael Mayer)
- (pages 183-190) Garbage Collection has effectively been deprecated by Apple in favor of ARC. You might want to skim that section anyway since some concepts (like zeroing weak references) apply, but for the most part you can rip out the pages and make origami boulders with them.
Chapter 8 : Debugging with GDB
- (page 213) "writing a test program can isolate the program faster" should be "writing a test program can isolate the problem faster"
Chapter 9: DTrace
- (page 233)
bottles--
should come before the final printf. (Thanks to Steve Nicholson)
Chapter 11
- (page 307) It says that
unlink()
removes a reference from a dictionary. It should of course say "directory". (Thanks to Steve Nicholson)
- (page 314) permissions for
ls -l test
shoud be -rwxrwxr-x
. The ones shown are actually 755. (Thanks to Jules Looker)
Chapter 13 : NSFileManager
- (page 368) URL operations - it says "invoke the same delegate methods." It actually invokes URL-flavored delegate methods analogous to the path-based ones, but take URLs instead of paths.
Chapter 14 : Network Programming With Sockets
- (page 396) Domain Name Lookup - The book says that
gethostbyname2()
is not thread safe. It actually is, allocating the "static structures" in thread-local storage. So feel free to call it on as many threads as you wish.
Chapter 18 : Multiprocessing
- (page 488) The example output from
uptime
doesn't match the text. It should be something like 0.5, 1.0, 1.0
. (Thanks to Ryan Lederman)
Chapter 21 : Operations
- (page 545) You'll want to add a
-bitmap
method, or change the property to nonatomic
to quiet a compiler error/warning about non-miscible getters and setters. Atomic properters have to be all compiler-generated, or all user-writte. Can't mix-n-match them like here. (Thanks to Jeff Sulton)
- (page 547) If you're using the LLVM compiler, you'll want to change
complex
to Complex
in the mandelbrot
function. (Thanks to Jeff Sulton)
- (page 548) CalcOperation's init needs to assign the _view instance variable. Otherwise the window won't redraw until you resize it. (Thanks to Ray Lipicky). If you don't retain _view in init, you'll need to remove the release from -dealloc. (Thanks to Jorge Carriera)
- (page 551)
MandelOpperAppDelegate
adopts the BitmapViewDelegate
- that's actually part of the solution to Exercise 1 (and exists in the source code drop) but isn't relevant to the initial Mandelbrot code. Thanks to Jeff Sulton)
- (page 553) The CalcOperations are not released after being added to the queue, leading to leaks. (Thanks to Jorge Carriera)
Chapter 22 : Grand Central Dispatch
- (not sure of the page yet)
dispatch_iterate.m
refers to the results
array and indexes it. This works because results
is global. If it were a local array, you'll get an error from the compiler: "Cannot refer to declaration with an array type inside block". That's because the array devolves into a just a pointer inside of the block, and the block machinery doesn't know how to capture it if the block is copied. This discussion on Apple's forums discuss strategies to address this problem. (Thanks to Matthew Carroll)
- (page 578) The use of the
CountAndSet
struct to return a pair of values from a method will fail with ARC. Change it to return a dictionary instead. (which is what it really should have done in the first place. mea culpa)
- (page 595) Exercise 5 is non-sensical. Please ignore. (Thanks to Chris Loper)