Last active
June 27, 2023 10:25
-
-
Save JaviSoto/5906004 to your computer and use it in GitHub Desktop.
Mark designated initializer at compile time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define MSDesignatedInitializer(__SEL__) __attribute__((unavailable("Invoke the designated initializer `" # __SEL__ "` instead."))) | |
// Sample usage: | |
- (instancetype)initWithObject:(id)object; | |
- (instancetype)init MSDesignatedInitializer(initWithObject:); // <- This even gets auto-complete. | |
// Now calling init on this class would throw a warning. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@haemi You would probably have to mark
+ (instancetype)new
in the same manner.