Created
November 9, 2016 17:14
-
-
Save petermolnar-dev/7d96204984e5f240014b7ac3c6286dd1 to your computer and use it in GitHub Desktop.
PMOPictureWithURL.m
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
#import "PMOPictureWithURL.h" | |
//1 | |
#define CLASS_NAME NSStringFromClass([self class]) | |
#define INIT_EXCEPTION_MESSAGE [NSString stringWithFormat:@"Use [[%@ alloc] initWithPictureURL:]",CLASS_NAME] | |
@implementation PMOPictureWithURL | |
#pragma mark - Initializers | |
- (instancetype)initWithPictureURL:(NSURL *)url { | |
if (url) { | |
self = [super init]; | |
if (self) { | |
_imageURL = url; | |
} | |
return self; | |
} else { | |
@throw [NSException exceptionWithName:@"Can't be initialised with null parameter" | |
reason:INIT_EXCEPTION_MESSAGE | |
userInfo:nil]; | |
return nil; | |
} | |
} | |
//Save the diagnostic state | |
#pragma clang diagnostic push | |
//Ignore -Wobjc-designated-initializers warnings | |
#pragma clang diagnostic ignored "-Wobjc-designated-initializers" | |
- (instancetype)init | |
{ | |
@throw [NSException exceptionWithName:@"Not designated initializer" | |
reason:INIT_EXCEPTION_MESSAGE | |
userInfo:nil]; | |
return nil; | |
} | |
//Restore the disgnostic state | |
#pragma clang diagnostic pop | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment