Created
January 22, 2014 16:47
-
-
Save shaps80/8562258 to your computer and use it in GitHub Desktop.
ProTip: Better way to raise an exception when -init is called on a class that implements a designated initialiser. Turn on -Wstrict-selector-match to get compiler warnings when this selector doesn't exist. Some IDEs (like AppCode) will even refactor this for you should you change the selector ;) The best thing about this is if its inside a stati…
This file contains 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
- (instancetype)init | |
{ | |
SEL selector = @selector(initWithName:); | |
[NSException raise:NSGenericException format:@"Please use %@", NSStringFromSelector(selector)]; | |
return nil; | |
} | |
- (instancetype)initWithName:(NSString *)name | |
{ | |
self = [super init]; | |
if (self) { | |
_name = name; | |
} | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment