Use a weak reference for TargetConfig configurations to avoid a circular reference...
[enjoyable.git] / TargetConfig.m
1 //
2 // TargetConfig.m
3 // Enjoy
4 //
5 // Created by Sam McCall on 6/05/09.
6 //
7
8 #import "TargetConfig.h"
9
10 @implementation TargetConfig
11
12 - (NSString *)stringify {
13 return [[NSString alloc] initWithFormat: @"cfg~%@", self.config.name];
14 }
15
16 + (TargetConfig *)unstringifyImpl:(NSArray *)comps withConfigList:(NSArray *)configs {
17 NSString *name = comps[1];
18 TargetConfig *target = [[TargetConfig alloc] init];
19 for (Config *config in configs) {
20 if ([config.name isEqualToString:name]) {
21 target.config = config;
22 return target;
23 }
24 }
25 NSLog(@"Warning: couldn't find matching config to restore from: %@", name);
26 return nil;
27 }
28
29 - (void)trigger {
30 [[(ApplicationController *)[[NSApplication sharedApplication] delegate] configsController] activateConfig:self.config];
31 }
32
33 @end