How would I check that NSRegularExpressionSearch exists before using it?
enum {
NSCaseInsensitiveSearch = 1,
NSLiteralSearch = 2,
NSBackwardsSearch = 4,
NSAnchoredSearch = 8,
NSNumericSearch = 64,
NSDiacriticInsensitiveSearch = 128,
NSWidthInsensitiveSearch = 256,
NSForcedOrderingSearch = 512,
NSRegularExpressionSearch = 1024
};
Update- I want to compile against the latest SDK and check at runtime if NSRegularExpressionSearch exists.
NSRegularExpressionSearchis only compiled whenSo you need to check that the current operating system is 3.2 or later.
In other cases you might check that a class exists or that an instance responds to a selector, but NSString did not change other than that enum. For example, if there was an enum associated with gesture recognizers you could use one of the following:
For another example, see how Apple handles the UI_USER_INTERFACE_IDIOM macro.
Edit:
A version number to check besides the system version is
NSFoundationVersionNumber.That is more closely tied to NSString, but there is no constant for 3.2 in the 3.2 headers.