Skip to content

Instantly share code, notes, and snippets.

@AlanQuatermain
Created April 12, 2012 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlanQuatermain/2369294 to your computer and use it in GitHub Desktop.
Save AlanQuatermain/2369294 to your computer and use it in GitHub Desktop.
Compatibility macros for NSNumber literals
#if __has_feature(objc_bool)
# define $YES @YES
# define $NO @NO
# define $i(x) @##x
# define $ui(x) @##x
# define $l(x) @##x
# define $ul(x) @##x
# define $ll(x) @##x
# define $ull(x) @##x
# define $f(x) @##x
# define $d(x) @##x
#else
# define $YES [NSNumber numberWithBool: YES]
# define $NO [NSNumber numberWithBool: NO]
# define $i(x) [NSNumber numberWithInt: x]
# define $ui(x) [NSNumber numberWithUnsignedInt: x]
# define $l(x) [NSNumber numberWithLong: x]
# define $ul(x) [NSNumber numberWithUnsignedLong: x]
# define $ll(x) [NSNumber numberWithLongLong: x]
# define $ull(x) [NSNumber numberWithUnsignedLongLong: x]
# define $f(x) [NSNumber numberWithFloat: x]
# define $d(x) [NSNumber numberWithDouble: x]
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment