Skip to content

Instantly share code, notes, and snippets.

@joelturnbull
Last active December 11, 2015 17:29
Show Gist options
  • Save joelturnbull/4634948 to your computer and use it in GitHub Desktop.
Save joelturnbull/4634948 to your computer and use it in GitHub Desktop.
Implementation of Party initializers deferring to a Designated Initializer
// Implementation of Party initializers deferring to a Designated Initializer
#import "Party.h"
@implementation Party
-(Party*)initWithLocation:(NSString*)location {
return [self initWithLocation: location date:[self defaultDate] attendees:[self defaultAttendees]];
};
-(Party*)initWithLocation:(NSString*)location date:(NSDate*)date{
return [self initWithLocation: location date:date attendees:[self defaultAttendees]];
};
-(Party*)initWithLocation:(NSString*)location attendees: (NSArray*)attendees{
return [self initWithLocation: location date:[self defaultDate] attendees:[self defaultAttendees]];
};
-(Party*)initWithLocation:(NSString*)location date:(NSDate*)date attendees:(NSArray*)attendees{
self = [super init];
self.location = location;
self.date = date;
self.attendees = attendees;
return self;
};
-(NSDate*)defaultDate {
return [NSDate date];
}
-(NSArray*)defaultAttendees {
return @[];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment