Skip to content

Instantly share code, notes, and snippets.

@brianmpalma
Created March 23, 2015 18:55
Show Gist options
  • Save brianmpalma/0eb440c53e6a941f6aee to your computer and use it in GitHub Desktop.
Save brianmpalma/0eb440c53e6a941f6aee to your computer and use it in GitHub Desktop.
VC initialization
// no new initializers defined in the .h
- (instancetype)init
{
self = [super initWithNibName:nil bundle:nil];
if (self) {
// do stuff
}
return self;
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
return [self init];
}
// initializer defined in .h
- (instancetype)initWithArchivedTasks:(BOOL)archivedTasks;
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
[NSException raise:@"Initializer Error:" format:@"Please use -initWithArchivedTasks:"];
return nil;
}
- (instancetype)initWithArchivedTasks:(BOOL)archivedTasks
{
self = [super initWithNibName:nil bundle:nil];
if (self) {
self.archivedTasks = archivedTasks;
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment