Skip to content

Instantly share code, notes, and snippets.

@paulofierro
Last active April 19, 2016 14:42
Show Gist options
  • Save paulofierro/4954870419e081258d50be49e3fb3ea3 to your computer and use it in GitHub Desktop.
Save paulofierro/4954870419e081258d50be49e3fb3ea3 to your computer and use it in GitHub Desktop.
Generify
// This gives lets us use generics when compiling with Xcode 7 but will still compile using Xcode 6
#if __has_feature(objc_generics)
#define _generify(CODE) <CODE>
#define _generify_dict(KEY_TYPE, VAL_TYPE) <KEY_TYPE, VAL_TYPE>
#else
#define _generify(CODE)
#define _generify_dict(KEY_TYPE, VAL_TYPE)
#endif
/*
NSArray <NSString *> *myList;
becomes
NSArray _generify(NSString *) *myList;
NSDictionary <NSString *, NSNumber *> *myDictionary;
becomes
NSDictionary _generify_dict(NSString *, NSNumber *) *myDictionary;
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment