In Objective-C
it was sometimes useful to use static string constants to define alternate API keys (for example to differentiate between RELEASE and DEBUG keys for analytics packages, like MixPanel, Flurry or Crashlytics):
#if DEBUG
static NSString *const API_KEY = @"KEY_A";
#else
static NSString *const API_KEY = @"KEY_B";
#endif
and then...
[Analytics startSession:API_KEY];
How does this translate to Swift, since the Swift compiler no longer uses a preprocessor?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…