Skip to content

Instantly share code, notes, and snippets.

@ahmedk92
Forked from aaronshekey/commonInit.m
Last active May 22, 2019 12:52
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 ahmedk92/1364ae8a3ee5abec32bf7663f06d14d4 to your computer and use it in GitHub Desktop.
Save ahmedk92/1364ae8a3ee5abec32bf7663f06d14d4 to your computer and use it in GitHub Desktop.
Common initialization methods for a custom view in Objective C
- (void)commonInit {
// Do stuff.
}
- (instancetype)init {
if (self = [super init]) {
[self commonInit];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self commonInit];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
[self commonInit];
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment