Skip to content

Instantly share code, notes, and snippets.

@Pretz
Created October 9, 2013 22:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pretz/6909690 to your computer and use it in GitHub Desktop.
Save Pretz/6909690 to your computer and use it in GitHub Desktop.
C macro for creating handy static constants in obj-c. Is this a bad or good idea?
#define STATIC_CONST(name) static NSString * const name = @#name;
STATIC_CONST(LearningNavRestorationIdentifier)
STATIC_CONST(ProfileNavRestorationIdentifier)
STATIC_CONST(ReservationsNavRestorationIdentifier)
#undef STATIC_CONST
// Becomes:
static NSString * const LearningNavRestorationIdentifier = @"LearningNavRestorationIdentifier";
static NSString * const ProfileNavRestorationIdentifier = @"ProfileNavRestorationIdentifier";
static NSString * const ReservationsNavRestorationIdentifier = @"ReservationsNavRestorationIdentifier";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment