Home > Articles > Home & Office Computing > Mac OS X

  • Print
  • + Share This
From the author of Portability

Portability

No discussion of new Cocoa features would be complete without talking a bit about portability. While the Cocoa APIs are nice, they are confined to a single platform and, with the newer APIs, to a single version of that platform.

GNUstep provides a complete implementation of the OpenStep specification, which is the core of the Cocoa APIs, and also adds a lot of Cocoa compatibility. This includes everything covered in this article, with some provisos.

The new forwarding proxy idea is a slightly less general form of something that I implemented for the Etoile runtime a few years ago. This was a research prototype, exploring future directions for Objective-C evolution. I've recently back-ported most of the improvements to a fork of the GNU Objective-C runtime, in the GNUstep subversion repository as libobjc2. This is still undergoing active testing, but should be included with the next GNUstep release. Among other things, it provides a new message lookup function that permits modification of the sender, so all of the new proxy methods will work, as long as you compile with Clang, which implements the new ABI.

The NSCache class was added a couple of days after 10.6 was implemented, and the auto-accessing proxy implementation in GNUstep supports both the old and new forwarding functions, so it will work with both the old and new runtime libraries, albeit with a speed penalty on the new one.

If you want to use NSCache on older versions of OS X, you can copy the code from GNUstep into a loadable bundle and load it when your application starts, if it is running on an older version of OS X. The new proxy support, because it only provides a faster path, can just be used in addition to the traditional forwarding mechanism, and will automatically be used on a platform where it is supported.

  • + Share This
  • 🔖 Save To Your Account