'Convert to Modern Objective-C Syntax'...
[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
11 @implementation TargetConfig
12
13 @synthesize config;
14
15 -(NSString*) stringify {
16 return [[NSString alloc] initWithFormat: @"cfg~%@", [config name]];
17 }
18
19 +(TargetConfig*) unstringifyImpl: (NSArray*) comps withConfigList: (NSArray*) configs {
20 NSParameterAssert([comps count] == 2);
21 NSString* name = comps[1];
22 TargetConfig* target = [[TargetConfig alloc] init];
23 for(int i=0; i<[configs count]; i++)
24 if([[configs[i] name] isEqualToString:name]) {
25 [target setConfig: configs[i]];
26 return target;
27 }
28 NSLog(@"Warning: couldn't find matching config to restore from: %@",name);
29 return NULL;
30 }
31
32 -(void) trigger {
33 [[(ApplicationController *)[[NSApplication sharedApplication] delegate] configsController] activateConfig:config forApplication: NULL];
34 }
35
36 @end