The Prototype
Cloning entities using NSCopying protocols.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Subschool: Replication
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// OBJC PATTERN //
@interface TKIllusion : NSObject <NSCopying>
@property (nonatomic, copy) NSString *visage;
- (instancetype)initWithVisage:(NSString *)visage;
@end
@implementation TKIllusion
- (instancetype)initWithVisage:(NSString *)visage {
if (self = [super init]) { _visage = visage; }
return self;
}
- (id)copyWithZone:(NSZone *)zone {
return [[[self class] allocWithZone:zone] initWithVisage:self.visage];
}
@end
Using NSCopying, the Prototype weaves identical copies of a conjuration, avoiding the heavy toll of reconstructing complex illusions.
Runic Tags:
#objc
#prototype
#creational