if (toRemove == manualConfig)
manualConfig = configs[0];
- // remove all "switch to configuration" actions
- for (Config *config in configs) {
- NSMutableDictionary *entries = config.entries;
- for (id key in entries) {
- Target *target = entries[key];
- if ([target isKindOfClass:[TargetConfig class]]
- && [(TargetConfig *)target config] == toRemove)
- [entries removeObjectForKey: key];
- }
- }
[(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged];
[tableView reloadData];
}
//
#import <Cocoa/Cocoa.h>
+
+#import "Target.h"
+
@class Config;
-@class Target;
-@interface TargetConfig : Target {
- Config *config;
-}
+@interface TargetConfig : Target
-@property(readwrite, strong) Config* config;
-+(TargetConfig*) unstringifyImpl: (NSArray*) comps withConfigList: (NSArray*) configs;
+@property (weak) Config *config;
++ (TargetConfig *)unstringifyImpl:(NSArray *)comps withConfigList:(NSArray *)configs;
@end
#import "TargetConfig.h"
-
@implementation TargetConfig
-@synthesize config;
-
--(NSString*) stringify {
- return [[NSString alloc] initWithFormat: @"cfg~%@", [config name]];
+- (NSString *)stringify {
+ return [[NSString alloc] initWithFormat: @"cfg~%@", self.config.name];
}
-+(TargetConfig*) unstringifyImpl: (NSArray*) comps withConfigList: (NSArray*) configs {
- NSParameterAssert([comps count] == 2);
- NSString* name = comps[1];
- TargetConfig* target = [[TargetConfig alloc] init];
- for(int i=0; i<[configs count]; i++)
- if([[configs[i] name] isEqualToString:name]) {
- [target setConfig: configs[i]];
- return target;
- }
- NSLog(@"Warning: couldn't find matching config to restore from: %@",name);
- return NULL;
++ (TargetConfig *)unstringifyImpl:(NSArray *)comps withConfigList:(NSArray *)configs {
+ NSString *name = comps[1];
+ TargetConfig *target = [[TargetConfig alloc] init];
+ for (Config *config in configs) {
+ if ([config.name isEqualToString:name]) {
+ target.config = config;
+ return target;
+ }
+ }
+ NSLog(@"Warning: couldn't find matching config to restore from: %@", name);
+ return nil;
}
--(void) trigger {
- [[(ApplicationController *)[[NSApplication sharedApplication] delegate] configsController] activateConfig:config];
+- (void)trigger {
+ [[(ApplicationController *)[[NSApplication sharedApplication] delegate] configsController] activateConfig:self.config];
}
@end