Skip to content

Instantly share code, notes, and snippets.

@petermolnar-dev
Created November 9, 2016 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petermolnar-dev/7d96204984e5f240014b7ac3c6286dd1 to your computer and use it in GitHub Desktop.
Save petermolnar-dev/7d96204984e5f240014b7ac3c6286dd1 to your computer and use it in GitHub Desktop.
PMOPictureWithURL.m
#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