X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Config.m;h=727b8b01a5c730824519b3deda548cb77a949918;hp=27ca4f0e91912a23585ecd6fbca2c4235e91e1af;hb=25dd74a4a34f4ba7ec797360bd8f92cbd7bc758e;hpb=51ca12b552a9c17c4d4029b0340e193b273044a8 diff --git a/Config.m b/Config.m index 27ca4f0..727b8b0 100644 --- a/Config.m +++ b/Config.m @@ -5,22 +5,32 @@ // Created by Sam McCall on 4/05/09. // -@implementation Config +#import "Config.h" --(id) init { - if(self=[super init]) { - entries = [[NSMutableDictionary alloc] init]; - } - return self; +@implementation Config { + NSMutableDictionary *entries; } @synthesize protect, name, entries; --(void) setTarget:(Target*)target forAction:(id)jsa { - [entries setValue:target forKey: [jsa stringify]]; +- (id)init { + if ((self = [super init])) { + entries = [[NSMutableDictionary alloc] init]; + } + return self; } --(Target*) getTargetForAction: (id) jsa { - return entries[[jsa stringify]]; + +- (Target *)objectForKeyedSubscript:(JSAction *)action { + return action ? entries[action.uid] : nil; +} + +- (void)setObject:(Target *)target forKeyedSubscript:(JSAction *)action { + if (action) { + if (target) + entries[action.uid] = target; + else + [entries removeObjectForKey:action.uid]; + } } @end