1

It might be best to start with an example: In OS X the following enum constants are defined in Foundation/NSString.h:

    NSCaseInsensitiveSearch = 1,
    NSLiteralSearch = 2,
    NSRegularExpressionSearch NS_ENUM_AVAILABLE(10_7, 3_2) = 1024

Questions:

  • At compile time, does the compiler simply replace NSRegularExpressionSearch with its constant value (1024)?
  • Or, is the constant value found at runtime, and if so, then what value is the constant when running on pre 10.7?
  • Is it advisable conditionally check at runtime what environment the program is running in before using the enum constant?
  • Is it always safe to put NSRegularExpressionSearch in my code even if it will run on a pre-10.7 runtime? (By safe I mean the presence of the constant alone won't cause a crash or exception; obviously I must account for the program's behavior when I use a constant value that an older API doesn't recognize.)
Steveo
  • 2,238
  • 1
  • 21
  • 34

0 Answers0