One of the things I've meant to do for ages is learn Objective C which is the variant of C used for programming on NextStep and hence on MacOS X. Ages back I bought a remaindered copy of Stephen G. Kochan "Programming in Objective-C (for which there is a 2nd edition available released earlier this year). I found it again over the weekend while looking for something else, and decided now was a good time to try working through some of it.
Typed in versions of the examples for the 2nd edition are available online, although these do differ somewhat from the examples in the first edition. Amongst other things, example 3.2 in the 1st edition inherits from Object directly, but example 3.2 in the 2nd edition inherits from NSObject (the NextStep core object, in the Foundation library). This is important because on Mac OS X 10.6 (Snow Leopard), the default build is 64-bit, and inheriting directly from Object does not work in 64-bit mode (build errors, and then runtime errors). But it does work when built in 32-bit mode. (I'm not clear what changed to break this; possibly the core Object wasn't really 64-bit safe so never got ported over.) (This thread on the Apple Discussion Board shows other people had the same idea using the same book and also encountered the problem when moving to Snow Leopard, which is the first to build 64-bit by default.)
From a hint on the Apple Discussion board the way to build in 32-bit mode so that these old examples still work is:
gcc -arch i386 -o example3-2 example3-2.m -lobjc
However other posts in that discussion indicate that the example should never have worked and only accidentally worked. I'm guessing that the author was trying to avoid introducing the Foundation library too early, but since the 2nd Edition example uses NSObject and the Foundation library it's presumably necessary.
Since I'm ornery about it, I'm going to keep trying to follow the 1st Edition and its examples at least until I understand more of the language and what's changed. But it's apparent that they're no longer representing Best Practice (tm). And it appears that very few people are coding in Objective-C outside of XCode.