Skip to content

Instantly share code, notes, and snippets.

@steipete
Created April 15, 2015 07:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steipete/2b352af0fef03d35d84f to your computer and use it in GitHub Desktop.
Save steipete/2b352af0fef03d35d84f to your computer and use it in GitHub Desktop.
#define PSPDF_NOT_DESIGNATED_INITIALIZER() PSPDF_NOT_DESIGNATED_INITIALIZER_CUSTOM(init)
#define PSPDF_NOT_DESIGNATED_INITIALIZER_CUSTOM(initName) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wobjc-designated-initializers\"") \
- (instancetype)initName \
{ do { \
NSAssert2(NO, @"%@ is not the designated initializer for instances of %@.", NSStringFromSelector(_cmd), NSStringFromClass([self class])); \
return nil; \
} while (0); } \
_Pragma("clang diagnostic pop")
@karolkozub
Copy link

@steipete it seems that the do { } while (0); wrapper is unnecessary.

@jonahb
Copy link

jonahb commented Mar 6, 2017

+1 to @karolkozub's comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment