How do I test for the existence of a Cocoa class at runtime that could be
absent on an earlier system?
The situation is that I want to use NSCache instead of NSMutableDictionary
somewhere. The object is created as a singleton when it's first used, but I
can't quite see how I should decide which class to make. I've read the
weak-linking guide and it makes sense, but the example in there shows only a
simple C function, not an Obj-C class.
I'm setting 10.6 SDK as my base SDK, but my minimum deployment target is 10.5.
Therefore NSCache will not be there on 10.5.
I thought I could do e.g.:
if([NSCache alloc] == nil ){ ... fall back to NSMutableDictionary ... }
but on 10.6 that actually calls [NSCache alloc] which I don't want, I just want
to test whether [NSCache alloc] (or any appropriate class method) actually
exists or not, or more precisely, whether NSCache exists. I'm guessing it's
easy and probably obvious when you know it, but I'm not seeing it.
--Graham
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]