Better constructor for Config.
[enjoyable.git] / Config.m
1 //
2 // Config.m
3 // Enjoy
4 //
5 // Created by Sam McCall on 4/05/09.
6 //
7
8 #import "Config.h"
9
10 #import "JSAction.h"
11
12 @implementation Config
13
14 - (id)initWithName:(NSString *)name {
15 if ((self = [super init])) {
16 self.name = name;
17 _entries = [[NSMutableDictionary alloc] init];
18 }
19 return self;
20 }
21
22 - (Target *)objectForKeyedSubscript:(JSAction *)action {
23 return action ? _entries[action.uid] : nil;
24 }
25
26 - (void)setObject:(Target *)target forKeyedSubscript:(JSAction *)action {
27 if (action) {
28 if (target)
29 _entries[action.uid] = target;
30 else
31 [_entries removeObjectForKey:action.uid];
32 }
33 }
34
35 @end