Skip navigation.
 
mlHow to ignore Tiger-only category methods on Leopard
FROM : Keith Blount
DATE : Wed Jan 30 23:00:13 2008

Hi,


I have an NSString category that defines and implements the following methods:


- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement options:(unsigned)opts range:(NSRange)searchRange;

- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement;



As of Leopard, though, both of these methods were introduced to the AppKit, so Leopard doesn't really need to use this category. It works fine - the category just overrides Leopard's implementation - but I would rather that Leopard's built-in methods were used when the app is run on Leopard rather than my category.


So, my question is, how do I have the preprocessor check the OS version so that it can skip these methods in an #if #endif block if the user is running Leopard?


Obviously, for stuff that should only be done on Tiger within methods, I can just use:


if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4)



But this won't work in a preprocessor #if #endif block because the preprocessor doesn't understand it, and all the other methods listed for checking this in the docs have the same issue from what I can see.


Is there a way to have these category methods skipped on Leopard? It's not really a big deal if not, given that it all works as expected anyway, but I figured there must be something silly I'm missing here.


Thanks in advance and all the best,
Keith



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs

Related mailsAuthorDate
mlHow to ignore Tiger-only category methods on Leopard Keith Blount Jan 30, 23:00
mlRe: How to ignore Tiger-only category methods on Leopard Nick Zitzmann Jan 30, 23:09
mlRe: How to ignore Tiger-only category methods on Leopard Mark Munz Jan 30, 23:14