X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Config.m;h=5a83ed30461deed4a4bfd44d4b6a993140571fa5;hp=de3c1cc970c278ed428591054175f3acd89815f6;hb=68fe4de58269fc00e70e59453e05098ccd4341a2;hpb=530009447c5bbd360ac5023979cffc6d32a28df3 diff --git a/Config.m b/Config.m index de3c1cc..5a83ed3 100644 --- a/Config.m +++ b/Config.m @@ -5,22 +5,31 @@ // Created by Sam McCall on 4/05/09. // +#import "Config.h" + +#import "JSAction.h" + @implementation Config --(id) init { - if(self=[super init]) { - entries = [[NSMutableDictionary alloc] init]; - } - return self; +- (id)initWithName:(NSString *)name { + if ((self = [super init])) { + self.name = name; + _entries = [[NSMutableDictionary alloc] init]; + } + return self; } -@synthesize protect, name, entries; - --(void) setTarget:(Target*)target forAction:(id)jsa { - [entries setValue:target forKey: [jsa stringify]]; +- (Target *)objectForKeyedSubscript:(JSAction *)action { + return action ? _entries[action.uid] : nil; } --(Target*) getTargetForAction: (id) jsa { - return [entries objectForKey: [jsa stringify]]; + +- (void)setObject:(Target *)target forKeyedSubscript:(JSAction *)action { + if (action) { + if (target) + _entries[action.uid] = target; + else + [_entries removeObjectForKey:action.uid]; + } } @end