🍏 OBJ-C RUNES DIFFICULTY: Adept Behavioral

The Chain of Responsibility

Passing requests along a sequence of wards.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Abjuration // Subschool: Sequences
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// OBJC PATTERN //
@interface TKWard : NSObject
@property (nonatomic, strong) TKWard *nextWard;
- (void)handleIntrusion:(NSInteger)powerLevel;
@end
@implementation TKWard
- (void)handleIntrusion:(NSInteger)powerLevel {
    if (self.nextWard) {
        [self.nextWard handleIntrusion:powerLevel];
    }
}
@end

@interface TKFireWard : TKWard
@end
@implementation TKFireWard
- (void)handleIntrusion:(NSInteger)powerLevel {
    if (powerLevel < 10) { NSLog(@"FireWard dispersed the threat."); }
    else { [super handleIntrusion:powerLevel]; }
}
@end

Chain of Responsibility establishes a gauntlet of protective wards. If a ward cannot contain an entity, the plea is passed sequentially down the chain.

Runic Tags: #objc #chain-of-responsibility #behavioral