Last active
December 11, 2015 17:29
-
-
Save joelturnbull/4634948 to your computer and use it in GitHub Desktop.
Implementation of Party initializers deferring to a Designated Initializer
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
// 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