How to #define an NSString for global use?

If you’re just concatenating strings, you can use compile time string concatenation:

#ifdef DEBUG
    #define kAPIEndpointHost @"http://example.dev"
#else
    #define kAPIEndpointHost @"http://www.example.com"
#endif

#define kAPIEndpointLatest          (kAPIEndpointHost @"/api/latest_content")
#define kAPIEndpointMostPopular     (kAPIEndpointHost @"/api/most_popular")

Leave a Comment