I am having trouble running different NSTask. One launchPath, another arguments. I have a class in which instances manage their own objects NSTaskand depending on the arguments that were initialized by these instances with the dependent NSTaskobject. I have two initializers:
- (void)taskFinished:(NSNotification *)aNotification {
[myTask release];
myTask = nil;
[self createTask];
}
- (id) init {
self = [super init];
if (self != nil) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(taskFinished:)
name:NSTaskDidTerminateNotification
object:nil];
[self createTask];
}
return self;
}
- (id)initWithCommand:(NSString *)subCommand {
self = [self init];
if (self)
{
[self setCommand:subCommand];
}
return self;
}
And here is the method createTask:
- (void)createTask {
myTask = [[NSTask alloc] init];
[myTask setLaunchPath:@"/usr/bin/executable"];
}
Actions are performed by selecting different rows in NSOutlineView (using PXSourceList as a wrapper):
- (void)sourceListSelectionDidChange:(NSNotification *)notification {
id sourceList = [notification object];
NSIndexSet *selection = [sourceList selectedRowIndexes];
NSString *identifier = [[sourceList itemAtRow:[selection firstIndex]] identifier];
MyCommand *command = [[MyCommand alloc] initWithSubcommand:identifier];
[command execute]
}
, . "click" ( ). , launchPath, , /bin/ls . 0 (.. ). gotchas .